This is a quick regular expression that matches all content before an underscore(_) in a string.
Can be useful in replacing all characters before an underscore in a set of usernames.
/^[^_]*_/g
Matches:
- regex_pattern
- 123_456
- abc_123_456
Non-matches:
- regex-pattern
- regex pattern
- regexpattern
See Also:
- Extract Text Before First Separating Character (Like Comma Or Space) With Regex
- Regex To Match The First Word Of Each Line In A Multiline Text Block
- Regex To Match Anything Except Underscore