Reputation: 51
I want to match the following 2 patterns.
The regular expression I'm using is ^[0-9]{5}|[0-9]{5}.[0-9]{5}$
. It is working for the first pattern but not the second. I have tested with Regex tester for .net and it is working. Can someone let me know what is wrong with my regex?
Upvotes: 1
Views: 828
Reputation: 162
Maybe you should use.
([0-9]{5})(\.[0-9]{5})*
You can test yours own regex expression in: https://regexr.com/
EDIT:
([0-9]{5})(\.[0-9]{5})|([0-9]{5})
Upvotes: -1
Reputation:
I tested it and that did not actually work for me. You should specify that '.' is a literal.
This works:
([0-9]{5})(\.[0-9]{5})?
Upvotes: 1