How to replace symbols?

Petr A December 14, 2021

Hi Dear community!

Trying to solve the issue: how to replace multiple symbols? 

Using this smart value to replace a // with a . in the field summary.

{{summary.replaceAll("//", ".")}}

But how to replace multiple characters, for example // and \ and &? 

Is it possible? 

Thanks a lot!

2 answers

1 accepted

2 votes
Answer accepted
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, 2021

Hi @Petr A 

Reading the documentation, the automation team indicates their regular expression parsing is "based upon Java's Pattern class", but no where is it fully documented what automation does and does not support for regular expressions.

I recommend experimentation with a simple, manual or scheduled triggered rule to learn what is possible.  For example, by testing I found character classes seem to work for replaceAll(), so you could try this:

{{issue.summary.replaceAll("[\&]", ".")}}

And then start chaining things which work to progressively remove things.  I found doing too much at once with automation rule RegEx doesn't lead to predicable results.

{{issue.summary.replaceAll("[\&]", ".").replaceAll("//", ".")}}

 

Kind regards,
Bill

Petr A December 15, 2021

Hi @Bill Sheboy 

As always, thank you very much)

Yes, with ReplaceAll + - understandable when you are dealing with one character. After several tests with errors, I already thought that multiple replacing does not work here.

But you gave me hope:D And after many errors this rule works for me and replaces &, /, \ symbols (for now anyway).

{{issue.summary.replaceAll("\\\\", ".").replaceAll("[\&]", ".").replaceAll("/", ".")}}

Have a good day!

Like Bill Sheboy likes this
0 votes
Reginald G_ Langar May 2, 2022

The question ❓ how explain itself to me based on the answers given herein. Thanks so much for your details explanation.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events