Help needed with smart values and regex match

Tobias Ladner
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2024

Hello,

I want to extract a user out of the issue description. The issue description might look like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

User: doejo

What I would like to extract is "doejo"

What I tried:

- {{issue.description.match("User:\s{1}\w{1,}").split(" ").get(1)}}

- {{issue.description.match("User:\s{1}\w+").split(" ").get(1)}}

- {{issue.description.match("User: \w{1,}").split(" ").get(1)}}

- {{issue.description.match("User: \w+").split(" ").get(1)}}

- {{issue.description.match("(?<=User:\s{1})\w{1,}")}}

-  {{issue.description.match("(?<=User:\s{1})\w+")}}

-  {{issue.description.match("(?<=User: )\w{1,}")}}

-  {{issue.description.match("(?<=User:)\w+")}}

 Nothing worked so far. Does someone know how I can make it work?

1 answer

1 accepted

1 vote
Answer accepted
Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 22, 2024

Hi @Tobias Ladner 

Welcome to the community!

You might want to try this:

{{issue.description.match(".*User:\s?(.*)")}}

With the assumption that "User: doejo" is always on a new line and show only once in your description.

Tobias Ladner
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2024

That worked, thank you very much. If I understand correctly, Jira always returns the first capture group, is that correct? If so is that documented somewhere? I used this documentation as well as other sources but I don't recall it being mentioned anywhere.

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 22, 2024

That is correct, it only return the first captured group.

It says so in the documentation you mentioned, maybe you overlooked it:

Performs a regular expression search and returns the first (and only one) matching regular expression group.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events