I need to try and match a string which is either a static @ or matches the pattern [^\d][\w\.\-]+.
I know I can use (...|...) to do or matches, but I can’t seem to get either @ or [^\d][\w\.\-]+ to match exclusively.
Here’s my current attempt: (@|[^\d][\w\.\-]+)
So, in this mean it would do match in the following manner:
'@' MATCH
'www' MATCH
'@www' NOT MATCH
'www@' NOT MATCH
'w@w' NOT MATCH
Any suggestions?
For the record this is doing a match in PHP 5.3.
If you can live with a whole string match, then add
^and$anchors.And the
[^\d]would match anything that is not a number. Anything would include@. So add an assertion: