REGEX to cover just first match from all


I have this type of regex


It’s not complete, this will match me many examples of 5 digit but I need just first and one match from this structure:

Reference Number            WW  
30966                     CFUN22       098765334    
30967                     CFUN22       098765335

30968                     CFUN22       098765336        
30969                     CFUN22    098765337

In this case I need just "30966" , not 30967,30968 and so on…

I tried to do


>Solution :

You can use a positive lookbehind to make sure that you’re grabbing the first 5-digit number after the word "Comments":


Leave a ReplyCancel reply