Regex To Match Everything After A Specific Character

Category: Strings

A regular expression that matches everything after a specific character (like colon, word, question mark, etc.) in a string.

Can be used to replace or remove everything in the text that starts with a certain character.

Note that don’t forget to replace the FOO as displayed below.

/\FOO(.*)/g

Matches:

  • FOOAbcdefg
  • FOO1234567
  • FOOABCDEFG

Non-matches:

  • FOAbcdefg
  • AFOObcdefg
  • 1234567FOO

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.