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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top