Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^2: regex to extract text

by jonnyfolk (Vicar)
on Jan 18, 2009 at 21:22 UTC ( #737180=note: print w/replies, xml ) Need Help??

in reply to Re: regex to extract text
in thread regex to extract text

Thanks for the fix and the advice - I'll be straight onto the parser!!

Replies are listed 'Best First'.
Re^3: regex to extract text
by graff (Chancellor) on Jan 19, 2009 at 07:46 UTC
    Note that CountZero's solution (based on your initial attempt, just adding the necessary "s" modifier) is doing a greedy match with '(.*)' -- this means that if there are two or more instances of '</div>' following the address section, the match will extend to the farthest one.

    Using '(.*?)' instead, to specify a non-greedy match, will do what you really want, though as pointed out already, you probably should be getting acquainted with proper HTML parsing. It takes a bit of learning to catch on, but in the long run a parsing module will lead you to quicker and better solutions than what can be done with regex matching.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://737180]
[Discipulus]: well i'm still at the end of the food chain..
[Discipulus]: so a new life as krill in prague will be good
[erix]: wtf -- what's the idea, is this trolling, advertising, or what?
[Discipulus]: but realisticly choroba your company would a hire a programmer as me?
Discipulus spent ~3 hours on the roof.. with mediocre results..
[Eily]: what were you trying to do on the roof Discipulus?

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-06-29 12:52 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (663 votes). Check out past polls.