How to match a line containing only a repeating character
I'm having difficulty designing a regex that will match a line of text that contains 0..n number of a specific character only.
Example: 0
01: foo,bar,blah,42
02: ,,,
Trying to match line 2.
I want to limit the match to a line that ONLY contains the specific delimiter I'm attempting to match on).
The regex should match on any number of the specific character (in my case, a comma), so it will not matter if there is 0 or 100.
I've tried using backreference to no avail. I'm using .NET f开发者_如何转开发or the regex if it matters, but I am not being picky. If an example can be shown in Perl, etc., I'll be happy to take it and figure out the conversion.
Suggestions?
I'm not sure I fully understand the requirement, but would this do it?:
^,*$
I assume for one value no comma is needed, try this (Perl-compatible):
^\d+:\s+(\w*,)*\w*$
精彩评论