Search multiple strings with replace formatter

Right now I have this formatter to search and replace a text:

{{typeBox.replace('09'', '"BIG')}}

It is possible to search for 09 but also 03 or 11 or 15 and replace it with BIG? Basically I want to search for more texts and replace it with BIG.

Thank you! :slight_smile:

I just store the result in a variable (Set Value) and then do the next .replace() on that variable …

But maybe there is slicker way! :thinking:

1 Like

Hi Antony, I don’t have much idea of what you said, im very newbie!

I am not good at coding, and I’m just learning WAppler! I was looking for an easy way to do it with the Wappler interface or with little custom code.

Okay!

I’m only on my phone at the moment… (midnight in the UK!), but in a server action, do something like this:

Set Value temp = $GET.my_string
Set Value temp = temp.replace(bla, bla)
Set Value temp = temp.replace(bla, bla)
Set Value temp = temp.replace(bla, bla)
Set Value temp = temp.replace(bla, bla)

If that makes sense!

1 Like

I’m not 100% sure if there is a way of doing this with an array but there might be i’m just not sure of the syntax, however a method that does work is appending more replaces in code view:

name.replace('m', 'p').replace('p', '2')

But take note this will run each replace after the one before it so for example the word:

Example would become Exa22le

As the m is made into a p and then the p’s are made into 2’s

1 Like