views:

518

answers:

2

Is there a regex pattern that will match a string that contains repeated pattern, e.g.:

"a"|"b","c"|"d",...,"y"|"z"

Do you have any idea?

Thanks.

+3  A: 

Maybe you are looking for something like this:

^"."\|"."(,"."\|".")*$

This will match a comma-separated list of sequences of form "α"|"β" where α and β can be any character.

Gumbo
Thanks, but it still match "a"|"b","c"|"d",aaa or "a"|"b","c"|"d",Can u fix it? Plz
NVA
I’ve added anchors for the start and the end of the string `^…$`.
Gumbo
@Gumbo: I am sure that "u can fix it". ;-) Deleting my answer, +1 for you.
Tomalak
A: 

Just a note that to truly look for a repeated pattern, you can use grouping like so:

<(htmltag>).*\1

where \1 refers to the matched string in the 1st group repeated. Make sense?

Eric Wendelin