![]() |
|
XP is just a number | |
PerlMonks |
Regex only returning partial databy Grey Fox (Chaplain) |
on Jun 06, 2008 at 17:29 UTC ( [id://690711]=perlquestion: print w/replies, xml ) | Need Help?? |
Grey Fox has asked for the wisdom of the Perl Monks concerning the following question:
Hello Fellow Monks;
I'm having a difficult time trying to get REGEX to stop after finding the first occurence of a string. I am extracting title information from an SGML file, and the regex is only returning partial information. I'm using the following regex. m/\s(?:-\s)?([\w\s\d()-,]{1,75})<\/title>/ against the following data.
Instead of getting "Grinding and Cutting Solution (ACME PR50 - Water Type)", I'm only getting "Water Type)", because of the second occurence of the " - " in the data. I know there is a way to make the regex only see the first occurence and then pass me all of the rest of the text up until </title>. I've looked at Perlre and http://www.regular-expressions.info/quickstart.html Thanks. Note: Added more examples
-- Grey Fox
"We are grey. We stand between the darkness and the light" B5
Back to
Seekers of Perl Wisdom
|
|