Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

why is regex ^[0-9][0-9][0-9][0-9] failing when checking '1446'. works in java regex checker

using regex validator against a field containing a 4 digit number (hour and minute of day), number is '1446', using  ^[0-9][0-9][0-9][0-9] and it is failing.  when i try the same in https://www.freeformatter.com/java-regex-tester.html#ad-output or in python 're' module, e.g. it works.

2 answers

2 accepted

1 vote
Answer accepted
Thomas Deiler Community Leader Apr 23, 2021

Dear @rob_zimmelman ,

I have no answer for your question, but dose this RegEx work?

[0-2][0-9][0-5][0-9]

I have proved this RegEx with following Java code:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("[0-2][0-9][0-5][0-9]", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher("1446");
boolean matchFound = matcher.find();
if(matchFound) {
System.out.println("Match found");
} else {
System.out.println("Match not found");
}
}
}

So long

Thomas

 this is working doing validation on the 'summary' field.

0 votes
Answer accepted

accomplished what i needed by making a sql query for GETDATE() which worked in the query comparison where the string comparison i was doing in regex with the string returned from an endpoint that returned 'hhmm' wasn't working

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM Jira Automation: How to Send SLA Breached Notifications

Hi Everyone, In   this tutorial,  we will show you how you can monitor an SLA, and send notifications before or after the SLA has been breached.   SLA Threshold Trigger The SLA t...

627 views 5 12
Read article

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