Regex: How to match a string containing a repeating pattern?

Is there a regular expression pattern that matches the string containing the repeating pattern, for example:

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

Do you have any ideas?

+3
source share
2 answers

Perhaps you are looking for something like this:

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

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

+4
source

Just note that to really look for a repeating pattern, you can use a grouping like this:

<(htmltag>).*\1

\1 1- . ?

+2

Source: https://habr.com/ru/post/1704792/


All Articles