sugar logic function: strReplace()

Hello there,

anybody please help with the strReplace?

I want to replace two characters inside a word: " " and "-" via Studio-->module--->fields---->edit formula(using logic function).

But when I write:  strReplace([" ","-"],"",$field)  it doesn't work....

How can I do that, please?

One more thing, if I will repeatably use one calculated result, can I create a variable there? Like this: 

$t = strReplace(" ","",$field)

strlen($t)

it looks like, I will get error...

Thanks in advance for any help!

Parents
  • sugarLogic function strReplace only support strings, not array. You should call it twice, one for " " and another one for "-".

    So the final formula would be strReplace(" ","",strReplace("-","",$field))

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi Andre,

    If my string has different other characters: -   .   ()  etc.

    How can I remove all characters except numbers?

    Thank you very much!

  • It can bee accomplished by creating a custom sugarLogic formula which uses regular expression for replacing any characters but numbers. This is not a big deal to do.

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi Andre,

     Thank you very much! 
    Could you please share some regular expression sample? Or the reference that I can study? I couldn’t find one...

  • You can create custom sugarLogic formulas by reviewing this article. You can understand how to build a regexp in js layer this way.

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply Children
No Data