in reply to Applying a regex to part of a string

substr($str,$start,$end-$start+1) =~ m/$regex/

Replies are listed 'Best First'.
Re^2: Applying a regex to part of a string
by holdyourhorses (Monk) on Aug 18, 2005 at 14:00 UTC

    That's already what I am doing in my first method. I was using a variable to make the example code look better. I should have mentioned that in real world cases I apply "substr" to the original string on the fly.

    Thanks anyway.

      Your substr is missing the +1 bit. It would only match between character positions 11 and 29, not 30.

        That's right. I missed that point. Fixed now.

        Thanks again.