high_flyer
26th August 2007, 17:24
Hi,
I want to match the following cases:
somename-123
somename_123
Where 'somename' should be any string of letters (any case) then a '-' OR a '_' and then optionally a number.
Here is my RegExp:
[a-zA-Z]+_|\-[a-zA-Z]+[0-9]
But it only matches 'somename_'. not 'somename-'
If switch between '_' and '-' so:
[a-zA-Z]+\-|_[a-zA-Z]+[0-9]
then only 'somename-' will match - so only the first between then two (\-|_) will match.
Why?
I tried also
[a-zA-Z]+(_|\-)[a-zA-Z]+[0-9] which matches nothing then.
Thanks in advance.
I want to match the following cases:
somename-123
somename_123
Where 'somename' should be any string of letters (any case) then a '-' OR a '_' and then optionally a number.
Here is my RegExp:
[a-zA-Z]+_|\-[a-zA-Z]+[0-9]
But it only matches 'somename_'. not 'somename-'
If switch between '_' and '-' so:
[a-zA-Z]+\-|_[a-zA-Z]+[0-9]
then only 'somename-' will match - so only the first between then two (\-|_) will match.
Why?
I tried also
[a-zA-Z]+(_|\-)[a-zA-Z]+[0-9] which matches nothing then.
Thanks in advance.