Regular Expression To Match Forward Slash

Category: Strings

Forward slash (/), usually appears at the end of URLs. It is a way to divide up long addresses, helping to create a more user-friendly URL. Also, it is used in the command line and search queries.

This is a Regular Expression that simply matches all forward slashes found in a string.

/\//ig

Explain:

  • \/ Escaped character. Matches a “/” character.

Matches:

  • /
  • //
  • ///

Non-matches:

  • abc
  • 123
  • \\\

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.