Regex to retrieve 8 number


#1

Hi Team,

I need regex to retrieve 8 digit numbers only

for ex. 12345678
1231234234234 - I want to retrieve only 12345678 Could anyone suggest please?
If i put \d{8} it selects both the numbers


#2

Use [0-9]{8}

Regards


#3

It selects both the numbers

regex

I want only the 8 digit numbers


#4

@Ula

try below regex patterns.

“[0-9]{8}[\S]”

“[0-9]{8}$”


#5

Thank you and it also not work as expected

regex


#6

This should work if the first string always ends with an end of line character:

(?=^)\d{8}$


#7

Thank you very much. It worked and also learned a new regex today.


#8

Okay Then Use This

^[0-9]{8}$

It Will Definetly work


#9

Thank you. It works perfectly