good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: find all repeating sequencesby kennethk (Abbot) |
on Dec 20, 2016 at 20:45 UTC ( [id://1178249]=note: print w/replies, xml ) | Need Help?? |
Please read Markup in the Monastery. Note how your square backets have been turned into a link. I see the bare </code> in your post, but that should have been written (I think) as
This also sounds a bit like homework, and a bit like you are getting ahead of yourself. As discussed in How do I post a question effectively?, think about what you are trying to do and where you are hitting issues. Are you sure your randomly generated strings contain what you think they do?. Where did you get the code you've posted. You have a \G in there, which does not really make sense in the context you're calling here. See Assertions in perlre for documentation. You are also inlining $_ into your regex, which makes no sense to me. And going for a non-greedy match, which is strange as well (see Metacharacters). What was the source material for this construction? Have you read perlretut for a basic description of what regular expression do? You probably want to use backreferences -- see Capture groups in perlre. Perhaps you confused \G and \g? You also probably want to use pos, $& and/or $-[0] in some combination to figure out positions, however you'd like to define that. So ending up with something like:
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In Section
Seekers of Perl Wisdom
|
|