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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

issue with regex on custom field validator with line breaks

my regext in Validators is:

The field Testing Instructions its contents must match against the regular expression ^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

testing instructions is a "Text Field (multi-line)" with a default of:

Developer add testing instructions in order to be allowed to set status to ready

When I have testing instructions with a line break such as

a
a

I get this error of not matching :(

Field Testing Instructions with actual value a a does not match regular expression ^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

It seems that you have tried to perform an illegal workflow operation.

If you think this message is wrong, please contact your JIRA administrators.

What can I do to allow line breaks in the value that I am validating?

--

What I am trying to do is require testing instructions field be filled out before transitioning to a status for testing. but sadly, Empty custom fields don't show on a ticket by default... and so I need to have a default value so I can't use field exists validators :(

1 answer

1 accepted

1 vote
Answer accepted

To turn on MULTILINE mode in a Java regular expression, put a “(?m)” in it. So, in your case, the regular expression would be

(?m)^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

The “(?m)” construct is an advanced feature. I’d go into it more, but the Atlassian site really isn’t the place to for it.

As an aside: what you really want is to say that the field does not match something, but I guess Jira on-demand doesn’t allow you to do that. So, you’re stuck with the weird negative-lookahead regular expression. That’s a pity.

@cedricThanks, but that isn't working, with a testing instructions field of

line 1 a

line 2 a

I still get the same error :(

Field Testing Instructions with actual value a a does not match regular expression (?m)^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

Oh, it must internally be using the matches() method of the Matcher class instead of find(). I’m not used to that.

In that case, you want to turn on the DOTALL mode. Use “(?s)” instead of “(?m)”. So you get

(?s)^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

That should do it.

We were running into the same exact issue, @Ced  your last suggestion from 9/1/2014  totally worked!  Thanks!

 

(?s)^((?!Developer add testing instructions in order to be allowed to set status to ready).)*$

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you