G
Guest
Hi,
I'm using RegExp to try and match a particular string value and can't figure
out why it's not working!
Possible valid values for the string are EITHER a single number (any length
of digits) OR a series of numbers, delimited by "|". (e.g. valid examples are
"1", "123", "123|", "123|456|", etc. The following would be invalid, "|",
"|123").
I've tried several things but only ever seem to match the first part e.g. :
(\d+\|)*|\d+ will match "123|" but not "123"
\d+|(\d+\|)* will match "123" but not "123|"
I eventually also want to anchor this with ^ and $. Can someone spot what's
wrong?
Thanks!
I'm using RegExp to try and match a particular string value and can't figure
out why it's not working!
Possible valid values for the string are EITHER a single number (any length
of digits) OR a series of numbers, delimited by "|". (e.g. valid examples are
"1", "123", "123|", "123|456|", etc. The following would be invalid, "|",
"|123").
I've tried several things but only ever seem to match the first part e.g. :
(\d+\|)*|\d+ will match "123|" but not "123"
\d+|(\d+\|)* will match "123" but not "123|"
I eventually also want to anchor this with ^ and $. Can someone spot what's
wrong?
Thanks!