regex - Repeated variable length regexp matching -



regex - Repeated variable length regexp matching -

i have expression

aa-bb/cc/dd

i want convert to

<aa-bb> <aa-cc> <aa-dd>

all can configure regexp substitution. can't figure out.

aa should match @ origin of line. - , / literal characters, bb,cc , dd numbers, i.e \d+

so first draft ...

^(\w+)([\-/]\d+)+

but want matches, not greedy one.

(actually 1 matches aa-bb-cc-dd too, that's ok although it's not according spec)

no, can't regex. .net, because there can access intermediate results of repeated capturing groups ...

repeating capturing grouping vs. capturing repeated group

that problem, if ^(\w+)([\-/]\w+)+ value stored in group2 lastly pattern matched. task not possible regex/replace.

i like:

^(\w+)-([\w+\/]+)

then split content of grouping 2 "/" , combine group1 each element of array resulting split.

regex

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -