Repeat a pattern in a RegExp without coding it all over??

  • Thread starter Thread starter Eidolon
  • Start date Start date
E

Eidolon

I have a regular expression essentially like the following:

(myPattern)(;myPattern)*

Is there a way to store the regexp in myPattern and then refer to it again
later by a short name?
the actual expression of myPattern is a bit long, and i was hoping i might
be able to get around having to have the same exact pattern repeated the
second time if its possible.

Thanks in advance,
- Eidolon
 
quick guess, try this one:

($<MyPatternGroup>myPattern)(;\k<MyPatternGroup>)*

equals

(myPattern)(;myPattern)*

For exxample

<(?<tag>\w*)></\k<tag>

would match

<p></p> or
<thisIsAVeryLongStringBelieveMe></thisIsAVeryLongStringBelieveMe>

Marc
 
quick guess, try this one:

($<MyPatternGroup>myPattern)(;\k<MyPatternGroup>)*

equals

(myPattern)(;myPattern)*

For exxample

<(?<tag>\w*)></\k<tag>

would match

<p></p> or
<thisIsAVeryLongStringBelieveMe></thisIsAVeryLongStringBelieveMe>

Marc
 
Back
Top