in reply to REGEX search for words not in quotes.
Another variant, using Text::Balanced, which is also always useful for parsing stuff with quoted, parenthesized, etc. parts:
#!/usr/bin/perl -l use strict; use warnings; use Text::Balanced qw(extract_delimited); my $text = 'SELECT "SELECT * FROM table1 WHERE ..." SQL FROM table2 WH +ERE ...'; my (undef, $remainder) = extract_delimited($text, '"', '[^"]*'); my ($extracted) = $remainder =~ /(\bFROM\b.*?\bWHERE\b)/; print $extracted; # FROM table2 WHERE
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: REGEX search for words not in quotes.
by Anonymous Monk on Apr 08, 2010 at 22:29 UTC |