Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Applying a regex to part of a string

by Roger (Parson)
on Aug 18, 2005 at 13:56 UTC ( #484769=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484769]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-12-09 23:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found