in reply to finding position of first occurence of 3 different stopping criteria

Try a regexp:
my $extract = $1 if $text =~ /^(.*?)($end1|$end2|$end3)/;

-Mark

  • Comment on Re: finding position of first occurence of 3 different stopping criteria
  • Download Code

Replies are listed 'Best First'.
Re: Re: finding position of first occurence of 3 different stopping criteria
by runrig (Abbot) on Sep 21, 2003 at 21:18 UTC
    If you just want the position of the start of match, then it's as easy as:
    print "Matched at $-[1]\n" if $text =~ /^.*?($end1|$end2|$end3)/;
    See perlvar for @- and @+ variables.

    Update: and this is along the same lines as Not_a_Number's post below. sorry for the redundancy...