I'm new to RegEx and I'm trying to match a specific number that has 8 digits, and has 3 start options:
For Example:
I don't want to match the 4th option. Right now I have managed to match the first and third options, but I'm having problems with the second one, I wrote this expression, trying to match the 8 digits under 'Project':
156204500|VS|00(?<Project>\d{8})
What should I do?
Thanks
With your shown samples, please try following regex once.
^(?:00|15620450000|VS)(\d{8})$
OR to match it with Project try:
^(?:00|15620450000|VS)(?<Project>\d{8})$
Online demo for above regex
Explanation: Adding detailed explanation for above.
^(?:00|15620450000|VS) ##Checking value from starting and in a non-capturing group matching 00/15620450000/VS here as per question.
(?<Project>\d{8} ##Creating group named Project which is making sure value has only 8 digits till end of value.
)$ ##Closing capturing group here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With