Skip to main content
Question

Regex problem

  • May 12, 2023
  • 2 replies
  • 117 views

Forum|alt.badge.img+2

Hi i want regular expression for the format e.g. JXN-12345-1, JXN-12875-2, ALA-3165-0 etc the values changes every time 
I’m using regular expression that is 
But it gives me False result(it gives me result that is not in this format) Please someone guide me where is my issue, how to resolve that issue
 


 

 

2 replies

Rohit Makhaik
Forum|alt.badge.img+4
  • Navigator | Tier 3
  • May 13, 2023

From the examples you’ve mentioned (JXN-12345-1, JXN-12875-2, ALA-3165-0) the Regex you are using is ^[A-Za-z]{3}-\d+-\d$.

The format you want looks like : 3 alphabets - any number of digits - single digit. You can add {1} for the last digit. ^[A-Za-z]{3}-\d+-\d{1}$$

If it doesn’t resolve, please give an example of false result which you are getting and don’t want.


Raul Jaimes
Forum|alt.badge.img+9
  • Navigator | Tier 3
  • May 13, 2023

@Aima Arif 

Try using the following:

^[A-Z]{3}-\d{4,5}-\d{1}$

 

Regards