Ok, I admit it; I don't really see the solution yet...
I have this script, among all the things it does is grep files for 'words';
The definition of a word is (as I thought in grep expression): "@[a-zA-Z0-9\.\-_]+@"
But it does not find a word like: '@foo.bar-test@'; which I thought it should detect.
The problem is that [[:alnum:][:punct:]] matches too much (eg: @foo=bar@)
I tried to use grep in various ways: grep -o -e, grep -o -E, grep -o -- etc
Also tried double-escaping the dash (it seems the only caharacter that is making issues is the dash, so focussing on that one now).
So far I've had the following commands to test it out:
Code:
echo "@foo.bar-match@" | grep "@[a-zA-Z0-9\.\-_]+@"
echo "@foo.bar-match@" | grep '@[a-zA-Z0-9\.\-_]+@' # different quotes
echo "@foo.bar-match@" | grep -e '@[a-zA-Z0-9\.\-_]+@'
echo "@foo.bar-match@" | grep -- '@[a-zA-Z0-9\.\-_]+@' # maybe the shell tries to interpret
echo "@foo.bar-match@" | grep '@[a-zA-Z0-9\.\\\-_]+@'
echo "@foo.bar-match@" | grep -e '\@[a-zA-Z0-9\.\-\_]+\@'
echo "@foo.bar-match@" | grep '@[a-zA-Z0-9\.[-]_]+@'
And a bunch more, actually, to add a bit of flavor. (e.g. combine -e and --), switch quotes, combine various ways of escaping; I'm a bit lost... why does grep not "see" this what should match...
Maybe one of the gurus immediately sees (as regexpes always give me headaches)