Reputation:
Find, for example in
yyyy , yyyy
yyyy,yyyy
yyyy, yyyy
yyyy ,yyyy
the pattern between yyyy and yyyy.
I've tried:
(\s*,{1}\s*)
but this will also match
yyyy,,yyyy
.
What is missing?
Upvotes: 3
Views: 52
Reputation: 6511
Using lookarounds:
(?<![,\s])\s*,\s*(?![,\s])
(?<![,\s])
is a negative lookbehind (?<!pattern)
. In this case, "not preceded by a comma or a whitespace"(?![,\s])
is a negative lookahead (?!pattern)
. In this case, "not followed by a comma or a whitespace"Upvotes: 1