Tutorial
Tools & Languages
Examples
Reference
Match Duplicate Comma-Delimited Items
(?<=
,
|
^
)
(
[^,]
*
)
(
,
\1
)
+
(?=
,
|
$
)
Options: ^ and $ match at line breaks
Assert that the regex below can be matched, with the match ending at this position (positive lookbehind)
Match either the regular expression below (attempting the next alternative only if this one fails)
Match the character "," literally
Or match regular expression number 2 below (the entire group fails if this one fails to match)
Assert position at the start of the string or after a line break character
Match the regular expression below and capture its match into backreference number 1
Match a single character not present in the list: one of the characters ","
Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match the regular expression below and capture its match into backreference number 2
Between one and unlimited times, as many times as possible, giving back as needed (greedy)
Note: You repeated the backreference itself. The backreference will capture only the last iteration. Put the backreference inside a group and repeat that group to capture all iterations.
Match the character "," literally
Match the same text as most recently matched by backreference number 1
Assert that the regex below can be matched, starting at this position (positive lookahead)
Match either the regular expression below (attempting the next alternative only if this one fails)
Match the character "," literally
Or match regular expression number 2 below (the entire group fails if this one fails to match)
Assert position at the end of the string or before a line break character
Welcome
Tutorial
Tools and Languages
Examples
Reference
About This Site
Download and Print