Regex To Match Anything Except Underscore

Category: Strings

A regular expression matches anything before and after an underscore(_) in a string.

/[^_\W]+/

Matches:

  • regex_pattern
  • 123_456
  • abc_123_456

Non-matches:

  • regex-pattern
  • regex pattern
  • regexpattern

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.