I was trying to split a string that was | delimited. Turns out .split("|") broke it into a list of individual characters. Instead .split("\|") had the intended effect.So | requires an escape character. What other characters require escaping? Add what you have found in the comments.
Hi @Aron Kuch
That is an interesting question, and I also find the escape-needing characters for rules (with and without the Atlassian implementation of regular expressions) are not documented...or at least not on the automation documentation pages :^)
I wrote a quick test rule, using most of the printable characters in a created variable to drive an advanced branch, using your split("|") technique, and then used each one to split the very same string without escaping. These are the ones which did not work at all (and so probably need to be escaped):
?$'()*+-.?|
And these seem context-dependent for the string being split:
"
The remainder all seemed to work, but I would test further if I needed this for a production rule. If you try the same test, please post what you find. Thanks!
Kind regards,Bill
Hi, a bit late, but I'd like to add that I noticed that replace() works fine when searching for single { but returns error when searching for double {{
I bet it's because the double curly creates confusion with smart variables delimiters.
Escaping the double curly doesn't seem to resolve the error...
Best regards
Hi @Fede B.
The parsing order can cause symptoms like that. One workaround is to use created variables. For example:
{{issue.description.replace(varSearchValue, varReplacementValue)}}
This also helps when using regular expressions, although there are extra steps to escape the characters.
It looks like you're new here. Sign in or register to get started.