Replace works sort of


#1

If you use :
replace(‘hello’,’l’,’w’). You will get hewwo as a result, that works as should.

But, if you use:
replace(‘hello (‘, ‘(‘, ‘a’). It won’t replace anything and errors out.

Seems it doesn’t like symbols. I have a workaround, but it is lengthy and would be so mush easier if it was straight forward.

BTW, if tried with both ‘ and “ and same result


#2

Try:

replace(“hello (”,"\(",“a”)


#3

Nope when I enter that as an expression, which I may not have mentioned, I get invalid paraders andvhello is not a variable


#4

Try this:
replace(“hello” ‘(’,’(’,‘a’)


#5

Solved the problem, please update the piston smart app - same version (don’t want to have everyone update for such a minor thing). Turns out String.replaceAll takes a Pattern as the search parameter, meaning that ( is a special character that groups search parts. I’ve made it use String.replace() instead, except for when using regex.

Also, the javascript is now capable of understanding the forward/backward single/double quotes that iOS seems to love using.

Let me know how it works, thank you.


Can I remove select words from a variable/expression?
#6


#8

Are you sure you updated (and published) the piston smart app?


#9

Sorry works now. For some reason when I updated it show up as edited. I had to publish for me and works now. Thank you so much. Much easier to replace now without having to count and mid and a bunch of girations to get it done. :clap:


#10

Not sure if this is related to the recent change, but the following used to work

replace(requestedChannel,"[^a-zA-Z0-9]",)

but now doesn’t seem to?
Any help would be greatly appreciated. I am in effect wanting to remove any non alphanumeric characters, including spaces etc.


#11

Seems i posted a little prematurely, i had been trying to get this to work for a a good few hours, but to no avail. After a few more experiments i have it sorted, i think

replace(requestedChannel,’/[\W_ ]/’,’’)

Is this the correct way to make this work?


#12

Yes, to use regexp, bookend the search expression with /