Regex To Match Comma Before & After A String

Category: Strings

A regular expression that allows you to match any comma before and/or after a string. Can be useful for removing all unexpected commas in an array.

Comma Before A String:



  • ,regex,pattern,com
  • ,,regex,pattern,com

Comma Before And After A String:



  • ,regex,pattern,com
  • regex,pattern,com,
  • ,,regex,pattern,com,

Has Whitespace:



  • , regex, pattern, com
  • ,, regex, pattern, com

See Also:

Rate This Regex
User Review
0 (0 votes)

Expression Flags

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