Help with Regex Expression- To fetch Alpha numeric and numeric values only

All, I am trying to extract only the 5 digit alpha numeric value (including both lower and upper cases & Numbers) and 5 digit numeric from any kind of sentence. My scenario should handle to pull only the above scenarios i have said. It should ignore 1. All alphabets, 2. Should ignore Alphabets with special characters.

From the above example, i have to get rid of the All alphabets and it should only pick J0585,64615,98909,AG456, 45TH4. Any suggestions? Appreciate your help. Thanks.

Hi,

How about the following pattern?

[A-Za-z0-9]{4}\d|[A-Za-z0-9]\d[A-Za-z0-9]{3}|[A-Za-z0-9]{2}\d[A-Za-z0-9]{2}|[A-Za-z0-9]{3}\d[A-Za-z0-9]|\d[A-Za-z0-9]{4}

Regards,

2 Likes

Nice to get response from you @Yoichi . Thanks , This expression isnt working… Did i miss something?

Hi,

Can you remove \b.*? at the beginning of the pattern? Do you need it for some reason?

Regards,

Oops! Sorry, My bad… I didn’t realize that. i was adding to the one which i was previously trying…
Yes, This Expression works perfectly fine :slight_smile: Thanks for your quick turnaround @Yoichi

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.