Log in

View Full Version : Solved: Regex to collect data after a search term and before the first of two others



Aquinax
06-22-2013, 11:59 AM
I need to fashion a regex with the following requirements:

SEARCH_TERM_#1(.*)SEARCH-TERM_#2_OR_#3

So the regex should collect data between SEARCH_TERM_#1 and SEARCH_TERM_#2 or #3 WITHOUT including the search terms, AND it should choose as the 'right-side' search border whatever it finds first of #2 and #3.

To be specific I need the collected data start after 'style="background-image: url(' and stop BEFORE either '&cfs=1' or '\);"' which ever comes first (the search terms without the quotes '...') My problem is that regex machine captures '&cfs=1' and stops before '\);"' although '&cfs=1' comes before '\);"' . I'm using PowerGrep with the command 'collect data'.

Thanks, all comments are welcome.

Aquinax
06-23-2013, 06:03 PM
I've got the answer (all credit to a user at stackover.com)

The regex which does the above described task is (among others I assume):

^.*?SEARCH_TERM_\#1((?:(?!SEARCH-TERM_\#2|SEARCH-TERM_\#3).)*)