0

I have the following problem that I'm trying to solve with String.replace:

I have a random text that contains IDs of tickets in some system e.g. JIRA-123. I want to replace then with Markdown links like so:

text.replace(/(JIRA-\d+)/g, "[$1](example.com?id=$1)");

The problem I'm struggling with is that I want this operation to be idempotent i.e. if a given ID is already wrapped in the URL I want it to be ignored and I'm struggling to figure out a correct expression to achieve that.

Any help?

Pawel Gorczynski
  • 1,227
  • 1
  • 15
  • 17

0 Answers0