in reply to Re: Re: Re: all matches
in thread all matches

let me ask you further:) I tried the code below $_="AHAAHKAKADL"; while ( /^(.)*(H)(.)*(K)(.)*(D)(.)*$/gx ) { print $1."\n"; print $2."\n"; print $3."\n"; print $4."\n"; print $5."\n"; print $6."\n"; print $7."\n"; print "-------\n"; # Restart the checking at one character after the match started. pos() = $-[0] + 1; } but that didn't work ask I expected. Actually my intention is dividing up the sequence in all combinations with patterns(these can be regex with willcards and all sort of-and the numberof patterns depends the user input) and keep the positions of the macthes of positions and length of the all patterns and the substrings in between. So I thought may be I could put them in a single pattern as the following: /^(.)*($pat1)(.)*($pat2)(.)*($pat3)(.)*$/ and match these to the whole sequence to extract the macthes and substrings in between, before and after. so above example is a simple case where patterns are single character. i would really appreciate any new point of view. thanks

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: all matches
by diotalevi (Canon) on Mar 26, 2004 at 15:01 UTC

    Oh I see. That's more difficult since perl's regex engine is designed to stop anytime it finds a match. You're after every possible match which is something I hear a POSIX regex engine will do by default. I'd be wary of trying to trick perl's engine with your trailing (?!) because the thing is designed to try to stop early and IIRC will try to avoid branches when possible, especially exponential permutations which is what you're after.

    Perhaps you should write your program in a language that has a POSIX engine instead.

      I had spent so much time on this. Thank you very much for your advice. hope I will be able to figure out POSIX engine. thanks a lot:)