Regex for specific length digit

Hii All,

I want to extract 4 digit length using regex from a string input. But if I use\d{4} it gets value from 123455 this number …i.e. 1st 4 digit. But I want only this type 1234 of 4 digit. Please help me

Hi @Ketan_Wajekar

Try ^\d{4}

Regards
Loveleet Saini

1 Like

Hi @Ketan_Wajekar

How about this expression?

System.Text.RegularExpressions.Regex.Match(YourString,"\b\d{4}\b").Tostring

image

Regards
Gokul

1 Like

Hi @Ketan_Wajekar ,

A better suggestion could be provided once we get to know the format of the String being used.

If you could provide us with Sample Data and it’s Expected Output, we could help you faster in achieving a Solution.

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