Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regex only returning partial data

by throop (Chaplain)
on Jun 06, 2008 at 17:54 UTC ( [id://690721]=note: print w/replies, xml ) Need Help??


in reply to Regex only returning partial data

There are three dashes in your example, not two. And a previous poster's comments about escaping the dash apply. So I'm unsure just what you're trying to do. Still, you're wanting to change the greedy behavior of [...]{1,75}. Check out What does it mean that regexes are greedy? in perlfaq6

throop

update: you've added more examples, so let me give you some more comments –

Are you ever going to have line breaks in your titles?
Are all your titles going to start with GRP?
I suggest:

m| \s* GRP \- \d+ (?: \s? \-\d+) # The GRP intro \s+ \- \s+ # The dash [\w\s\d()\-,]{1,75} # I have doubts about this <\/title> |xms
If this looks unfamiliar, check out How can I hope to use regular expressions.. I have some doubts that you really want the spec [\w\s\d()\-,]{1,75}. That is, are you really confident that you're not going to see a line like
<title> GRP-124-9 - Alkaline Rust Remover Solution (Yugo HTP-1150L - R +ust &amp; Stain Remover)</title>
and lose on the '&amp;'?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2025-03-16 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (54 votes). Check out past polls.