Entering An Expression


#1

In the following piston. I set a string variable which consists of several things strung together. Then I output that string in a push. It works fine.

I want to massage the string. So I wanted to put a StringReplace function before outputing to the push. But for some reason I can’t find how to input a function or expression. I know I’ve done it before, but the option never shows up. what am I doing wrong?


#2


#3

I see my mistake from before, but I get an error now. what I am trying to do is remove the [ and ] from the string.


#4

Try escaping them… ‘\]’ and ‘\[’

Argh, the forum is escaping my escape LOL


#5

Still doesn’t seem to be right. When I enter the expression:

replace({Weather_Alert_Message},’[’,’’,’]’,’’)

I see this Java.util.regex.PatternSyntaxException:UnclosedCharacter Class Near Inde…

Can’t seem to see the rest of the error.


#6

replace({Weather_Alert_Message},’\[’,’’,’\]’,’’)

even like the above?


#7

Make sure to use the regular ’ not the Apple-like ’ fancy single quote.


#8

Here’s the exact statement I am using:

replace({Weather_Alert_Message},’[’,’’,’]’,’’)

I tried with and without the . Also I only have the one single quote on my keyboard that I know of. It’s the one just to the left of the enter key with the shifted being the double quote.

Just realized the slash mark is not showing up in this post but it is in the piston. Not sure why the post won’t show it.


#9

Here’s the whole piston. Trying to see if the slash mark shows up now.


#10

One more try… try copying and pasting the code below so it will get the single quotes.

replace(Weather_Alert_Message,'\\[','','\\]','')


#11

You do not need the expression construct { } inside a function. You can get rid of the { } around the variable name.


#12

Finally got it to work. Removed the expression construct on the variable. That didn’t fix it. Then I put a double slash on the first part and that fixed it. Didn’t have to put a double slash on the second part. Not sure why. Here is what I ended up with. Hope the slashes show up.

replace(Weather_Alert_Message,’\[’,’’,’]’,’’).

There is a double slash right before the [. Still don’t know why it won’t show up on this post.


#13

They don’t show because \ is an escape character for a lot of languages and they remove that for display. The construct { } being removed would not “fix” anything, but would optimize a rather unnecessary extra burden.

Glad you got it to work, I’ll look into the \\ thing.


#14

Thanks for all the help. I understand the \ being an escape code, but would think in a text post it wouldn’t matter. Especially since posts by others showed it ok. No big deal, just puzzling.