How can I exclude some characters from a class?
Use a negated class including \W or \S. /[^\W_]/ # anything that’s not a non-word character and not _ /[^\S\t]/ # anything that’s not a non-space character and not \t
Use a negated class including \W or \S. /[^\W_]/ # anything that’s not a non-word character and not _ /[^\S\t]/ # anything that’s not a non-space character and not \t
egrep doesn’t recognize \d shorthand for digit character class, so you need to use e.g. [0-9]. Moreover, while it’s not absolutely necessary in this case, it’s good habit to quote the regex to prevent misinterpretation by the shell. Thus, something like this should work: egrep ‘[0-9]{7}-[0-9]{10}’ file See also egrep mini tutorial References regular-expressions.info/Flavor comparison … Read more
\p{L} matches a single code point in the category “letter”. \p{N} matches any kind of numeric character in any script. Source: regular-expressions.info If you’re going to work with regular expressions a lot, I’d suggest bookmarking that site, it’s very useful.