Regular Expressions 101

Comment Separator in Regex

Open Workspace
  • PCRE (Legacy)
  • Match
1

Regular Expression

/
(?:(.*)?((?:\/\/.*|--.*|\/\*.*\*\/))(.*))
/
g

Description

Works for all types of comments and even multiline comments in java.

Submitted by Chandan