Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Regex "does not match" ...doesn't match if theres two matches at the start.

jshippy April 19, 2022

Using the following filter, and it's been pretty decent thus far, until someone chatted a comment that started with:

"Thank You!

thank you,

..."

Tested variations on the comment, and getting rid of the second thank you line causes the rule to behave as intended (don't transition back to in progress) but two "thank you" comments in a row breaks things. I tested the pattern against regex101.com with the Java 8 flavor, and it matches twice. Is there some quirky backend engine detail thats causing this behavior? Is there something that can be adjusted in my pattern to work around this odd behavior?

 

Thanks in advance.


The pattern:

^[Tt][Hh][AaxX][Nn]?[Kk]?s? ?[Yy]?[Oo]?[Uu]?.*

 


Screen Shot 2022-04-19 at 10.11.19 AM.png

 

 

1 answer

1 accepted

1 vote
Answer accepted
Ed Gaile _Atlanta_ GA_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2022

Try the following and see if that gets you what you need.  Should only match only the first instance.

^[^%]*[Tt][Hh][AaxX][Nn]?[Kk]?s? ?[Yy]?[Oo]?[Uu]?[^%]*$ 

jshippy April 19, 2022

My requirements are "Thank You" in some form, but ONLY at the very start of the comment, as we don't want to affect users who respond via email with "Thank You" in their email signature (which is common in our locale)

Looks like /A and ^ have different behaviors, so this seems to be working:

\A[Tt][Hh][AaxX][Nn]?[Kk]?s? ?[Yy]?[Oo]?[Uu]?[^%]*$

Minor tweaks to your suggestion got me where I wanted. Thank you Sir!

Like Ed Gaile _Atlanta_ GA_ likes this
jshippy April 22, 2022

Well this grew past this original question. Thank You's were still getting past, so I started having it output to Microsoft Teams, and found the {{comment.body}} I was checking regex against had {color:#000000} text at the front of the line. Yey.

So I'm up to:

\A(\{.*\}\n?\s?|<.{0,5}>|[_+*\-])*[Tt][Hh][AaxX][Nn]?[Kk]?s? ?[Yy]?[Oo]?[Uu]?[^%]*$

for my filtering regex to address the presence of one or more leading {} blocks before "Thank You!", also looking for <> HTML blocks (which probably aren't in there) and an assortment of Markdown Characters, which could be used for underline, bold, etc. This looks to be effective in my testing, hopefully others will get some mileage out of this.

 

I've referenced this thread and documented here:
https://community.atlassian.com/t5/Jira-Service-Management/Using-automation-to-prevent-reopening-when-a-customer-comments/m-p/2009642#M2847

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events