JVMX
JVMX

Reputation: 1078

Regex pattern containing know length integer and unknown length integer

I need a regex pattern to find a number like: 1234567-4

Thanks in advance!

Upvotes: 0

Views: 40

Answers (2)

Jay
Jay

Reputation: 2686

If the first digit can not be 0

[1-9]\d{6}-\d+

if the first digit can be 0

\d{7}-\d+

Upvotes: 2

brandonscript
brandonscript

Reputation: 72885

Depending on the language you're using, this ought to do it:

^\d{7}-\d+$

Example and explanation: http://regex101.com/r/jM0bN5/1

Upvotes: 1

Related Questions