0
votes

I know it is maybe a simple question but i couldn't find the correction of my regex after an hour so i decided to ask it.

What I'm trying is :

^[0-9]{14}.*?_[0-9]{13}$

for the strings

58300000164329_1422947665835
58300000168754_ARA_DE_A_1422947398449
Customer_information_Refrigeration_Transition_1421678259290
58300000157376_ara_es_d_1421678030359
20120612_6_1421677861200

The main thing is starting with 14 numbers and ending with '_' and 13 numbers. Where is the problem in my regex ?

Any help would be appreciated, thanks a lot!

1
Which of these strings are invalid? Your regex does not match Customer_information_Refrigeration_Transition_1421678259290 and 20120612_6_1421677861200, do you want to match them? See regex101.com/r/iJ6dJ7/1.Wiktor Stribiżew

1 Answers

1
votes

In your regex, you need to add 2 _. One that will be always there and other one is optional.

Use this updated RegEx:

\b([0-9]{14}_)?.*_?[0-9]{13}\b

RegEx Demo & Explanation

EDIT:

Based on your comment, use this RegEx: .*_[0-9]{13}\b

Demo & Explanation