Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Value Escaped Characters

Aron Kuch
Contributor
November 30, 2023

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.

3 answers

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2024

Hi @Fede B. 

The parsing order can cause symptoms like that.  One workaround is to use created variables.  For example:

  • action: create variable
    • name: varSearchValue
    • value: some text containing {{
  • action: create variable
    • name: varReplacementValue
    • value: some replacement text
  • action: something needing the replace
{{issue.description.replace(varSearchValue, varReplacementValue)}}

This also helps when using regular expressions, although there are extra steps to escape the characters.

Kind regards,
Bill

0 votes
Fede B.
Contributor
June 17, 2024

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

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2023

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events