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
More Related Contents:
- Why is a character class faster than alternation?
- string pattern matching using perl regex [closed]
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- I would like remove only spaces and ignore tabs in a string
- Match whitespace but not newlines
- Exclude characters from a character class
- Using alternation or character class for single character matching?
- Verbs that act after backtracking and failure
- What regex can match sequences of the same character?
- How to extract string following a pattern with grep, regex or perl [duplicate]
- regex to match word boundary beginning with special characters
- Regex to match any character including new lines
- Does the ‘o’ modifier for Perl regular expressions still provide any benefit?
- How do I handle special characters in a Perl regex?
- Why do ^ and $ not work as expected?
- How can I find the location of a regex match in Perl?
- Can I use Perl regular expressions to match balanced text?
- How do I perform a Perl substitution on a string while keeping the original?
- Does \w match all alphanumeric characters defined in the Unicode standard?
- How can I parse quoted CSV in Perl with a regex?
- how to match a number which is less than or equal to 100?
- How can I match double-quoted strings with escaped double-quote characters?
- Is There a Way to Match Any Unicode Alphabetic Character?
- How to escape dollar sign ($) in a string using perl regex
- Capturing text before and after a C-style code block with a Perl regular expression
- Can I substitute multiple items in a single regular expression in VIM or Perl?
- How do I search and replace across multiple lines with Perl?
- How to use different separators (/ , |) in a regular expression
- Counting number of occurrences of a string inside another (Perl)
- How to replace a string in an existing file in Perl