Scriptrunner RegEx for start of string?

Erik Schumann January 7, 2025

Hi.

I have a customfield, that includes a mullti select list with structured information. I try to find a query, that returns any items that start with a certain substring.

Values in the list could be

ABC bla bla bla*

DEF bla bla bla* 

but also

ABC DEF bla bla*

I want to contruct a qeury that returns only issues with the strings starting with DEF.

A query issuefunction in issueFieldMatch("filter = 'filter name'", customfield_12345, "DEF") returns both "DEF bla bla" and "ABS DEF bla bla" as expected.

However a query issuefunction in issueFieldMatch("filter = 'filter name'", customfield_12345, "^DEF") or a query issuefunction in issueFieldMatch("filter = 'filter name'", customfield_12345, "^DEF.*$") retrun zero items.

What am I missing or doing wrong?

1 answer

0 votes
Tuncay Senturk
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 8, 2025

Hi @Erik Schumann 

I am not 100% sure but in regular expression (?m) enables multiline mode so it is worth trying the below one.

 

issueFunction in issueFieldMatch("filter = 'filter name'", customfield_12345, "(?m)^DEF.*")

 

Erik Schumann January 8, 2025

Thanks Tuncay.

 

Didn't think about that. The (?m) didnt't solve the problem, but got me thinking in the right direction. Thanks for that. 
The multi select list is not parsed as a set of strings, so I need to prefix with (^|\\s|,) and postfix with a negation, to exclude the bla bla from ABC DEF bla bla.

So thanks for getting my thoughts in the right direction.

Cheers,
/Erik

Tuncay Senturk
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 8, 2025

It makes sense. I'm glad it helped you think in the right direction. 

Kev February 28, 2025

Hi @Erik Schumann

Can you share your final expression please?

I'm doing a similar query where I only want labels that start with an exact three letters "iBC" and I don't want "ABC_iBC", if that makes sense?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events