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.<title>GRP -134 - Grinding And Cutting Solution (ACME PR50 - Water Typ +e) </title> <title> GRP-123-1 - Grinding And Cutting Solution (Quakeroat 2780 UTC +- Synthetic Type)</title> <title> GRP-124 - Alkaline Rust Remover Solution</title> <title> GRP-124-1 - Alkaline Rust Remover Solution (Ardvark 185 - Rust + Remover)</title> <title> GRP-124-2 - Alkaline Rust Remover Solution (Ardvark 185L - Rus +t Remover)</title> <title> GRP-124-3 - Alkaline Rust Remover Solution (Bee-Dee J84AL - Ru +st Remover)</title> <title> GRP-124-4 - Alkaline Rust Remover Solution (Mag HD2-202 - Rust + Remover)</title> <title> GRP-124-5 - Alkaline Rust Remover Solution (Turk 4181L - Rust +Remover)</title> <title> GRP-124-6 - Alkaline Rust Remover Solution (Turk 4181 - Rust R +emover)</title> <title> GRP-124-7 - Alkaline Rust Remover Solution (Bee-Dee J84A - Rus +t Remover)</title> <title> GRP-124-8 - Alkaline Rust Remover Solution (Cadilac HTP-1150 - + Rust Remover)</title> <title> GRP-124-9 - Alkaline Rust Remover Solution (Cadilac HTP-1150L +- Rust Remover)</title> <title> GRP-124-10 - Alkaline Rust Remover (Titanium Long Soak)";
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 examplesIn reply to Regex only returning partial data by Grey Fox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |