Regular Expression Expression Inquiry

000-00-00000
000 - 00 - 00000

How should I write a regular expression that satisfies the above one or two?

I was using ([0-9]{3})-([0-9]{2})-([0-9]{5})

“-” It’s not being collected properly.

Hi,

How about the following?

[0-9]{3}\s*-\s*[0-9]{2}\s*-\s*[0-9]{5}

OR

The following might be better if you need to exclude the first part digits is 4 or more (or last part digits is 6 or more)

\b[0-9]{3}\s*-\s*[0-9]{2}\s*-\s*[0-9]{5}\b

Regards,

I love you, thanks you so much

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