Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The problem is not with the (\w{2,}?), because it will happily match to ab in $x =~ /((\w{2,}?).*\g2.*?)+/;and $x =~ /((\w{2,}?).*?\g2.*?)+?/;You are asking the regex to give you a sequence which is repeated, and you can either get the longest match (greedy) or the shortest one (ungreedy) The only solution for your problem that I can think of, is to capture all matches that this regex finds (list context), then counting how often each captured sequence occurs, and selecting the one that occurs most often. In reply to Re: RegEx + vs. {1,}
by Anique
|
|