Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Matching starting at a certain position

Expand Messages
  • Jeff Eggen
    ... Jeff I think you could just use a single regex: Jeff if ( $String1 =~ m/^.{$start_at}$String2/ ) Jeff ... ... { ... } Y know, my first instinct was to
    Message 1 of 3 , Oct 1, 2003
    • 0 Attachment
      >>> merlyn@... 10/01/03 04:30pm >>>
      Jeff> I think you could just use a single regex:

      Jeff> if ( $String1 =~ m/^.{$start_at}$String2/ )
      Jeff> ...

      >No, that'll fail if:

      > 1) $start_at is greater than 255
      > 2) $String1 contains newlines
      > 3) $String2 contains regex metachars

      >Better solution:

      > if (substr($String1, $start_at, length($String2)) eq $String2)
      { ... }

      Y'know, my first instinct was to use substr(), but I thought I'd get
      shouted down in favor of a regexp. I should stick with my gut instincts
      :-P Thanks Randal!



      Jeff Eggen
      IT Programmer Analyst
      Saskatchewan Government Insurance
      Ph (306) 751-1795
      email jeggen@...
    Your message has been successfully submitted and would be delivered to recipients shortly.