How to detect 'end of string' in regex
I have a simple regular expression looking for twitter style tags in a
string like so:
$reg_exUrl = "/@([A-Za-z0-9_]{1,15})/";
This works great for matching words after an @ sign.
One thing it does though which I don't want it to do is match full stops.
So it should match
"@foo"
but should not match
"@foo."
I tried adding amending the expression to dissallow full stops like so:
$reg_exUrl = "/@([A-Za-z0-9_]{1,15})[^\.]/";
This almost works, except it will not match if it's at the end of the
string. EG:
It WILL match this "@foo more text here"
but won't match this "@foo"
Could anyone tell me where I'm going wrong?
Thanks
 
No comments:
Post a Comment