in reply to Re^3: Need RegExp help - doing an AND match
in thread Need RegExp help - doing an AND match

Yes, I know what you mean but I'm not matching explicit text - here is an example:
@words = ("filename" , "file.txt"); $line = "my file is file.txt";
I want to search this line and save it in a variable for later. These work assuming no lines contain both words:
$file = (grep{$line =~ /$_/i} @words)[0]; or foreach (@words) { next if($line !~ /$_/i); $file = $_; }
So both work ($file is nonempty) but not good.
Problem is that I will need to pass a variable into my RegExp for my search - which may or may not contain a "."

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

    You seemed to have missed the quoting of dot part in Corion's reply. In any case, refer to the quotemeta function description, usage of which would be something like ...

    my @words = map { quotemeta $_ } ( "filename" , "file.text" );