in reply to Re^3: Need RegExp help - doing an AND match
in thread Need RegExp help - doing an AND match
I want to search this line and save it in a variable for later. These work assuming no lines contain both words:@words = ("filename" , "file.txt"); $line = "my file is file.txt";
So both work ($file is nonempty) but not good.$file = (grep{$line =~ /$_/i} @words)[0]; or foreach (@words) { next if($line !~ /$_/i); $file = $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Need RegExp help - doing an AND match
by parv (Parson) on Jul 01, 2007 at 21:12 UTC |