3

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?

2
  • Could you give some examples? Commented Mar 15, 2009 at 17:16
  • +1 on examples. Do you mean "any repeated pattern" or the specific pattern you mentioned? Give some examples and counter-examples. Commented Mar 15, 2009 at 17:17

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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

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?

1 Comment

Yes, it makes sense and it should be marked as the more correct answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.