Forums

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

Automation: Regex doesn't work for long URLs

Josh January 25, 2024

Hi there all,

We use Jira to (amongst other things) track support queries. It works well apart from one unfortunate side effect that's nothing to do with Jira itself - part of our IT Security setup rewrites URLS, which is great except for making support tickets less readable. Here's an example:

On the login screen <https://urldefense.proofpoint.com/v2/url?u=https-3A__blah.blah-2Dblah.com_&d=posdFAg&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_C22asddpgnVfiiMr=q_bJBgAAsdf1bS6AezokJqD2Ppp_bUa_-jY2BP3asd4S5wTQadsyE&m=UXmIPLFgwwo5ykvT7OsGLAuyqpntd-oHtcE324EY6YclbbvVGOGxfD2n0lEuuYPGE&s=eG0WqTpPy3cdWy6zx!87ynzuzwWPh0MYHpEjjAP1TMM&e=>, is it possible to either 

I can't control that so I figured 'hey, I'll make an automation that removes those URLs for readability purposes!' (we can access the actual mailbox if we need to see the real URL so we don't lose the info)

I've created other automations using regex that work fine but this one doesn't work at all. Maybe the URLs are too long to remove, or I'm doing something wrong with escaping characters, I'm not sure. Here's what I've got at the moment:

{{issue.description.replace("<https:\/\/urldefense.*>","")}}

What I'm trying to do is find anything that matches the format

<https://urldefense [anything else]>

But no luck - the automation logs say it's run successfully but nothing actually happens.

My other automations (including those that use regexs to edit case descriptions) all work fine.

Apologies if I've missed anything out here in my question. I've tried Regex validators and they say it should work, tried experimenting by playing around with the actual regex in case Jira didn't like escaping those characters ((".*urldefense.*") for example) but no luck. I asked ChatGPT and it suggested double slashes for escaping (so \\/\\/) but that didn't work either.

 

Maybe it can't be done but I thought I'd ask here just in case :)

 

Thanks for reading!

1 answer

1 accepted

1 vote
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.
January 25, 2024

Hi @Josh -- Welcome to the Atlassian Community!

The replace() function is a plain text search / replace and the replaceAll() is the one which uses a regular expression, so please try replaceAll().  If you instead want to extract the values, try using the match() function with a regular expression.

Also please note, the documentation on what is / is not supported with regular expressions and rules is vague, at best.  I recommend starting as simple as possible, writing values to the audit log, and slowly building up an expression to meet your needs.  That will reveal if you try to use a regular expression construct which is not supported.

Kind regards,
Bill

Josh January 26, 2024

Hi Bill, thanks for your suggestions - switching replace for replaceAll did the trick :) Much appreciated! Josh

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer