G'day JLowstetter,
Welcome to the monastery.
I'd use qr for that. See perlop: Regexp Quote-Like Operators for details.
#!/usr/bin/env perl use strict; use warnings; my @lines = ("MyName='Custom'\n", "MyName!='Custom'\n"); my $re = qr{MyName='Custom'}; for my $line (@lines) { if ($line =~ $re) { print "MATCH: $line"; } else { print "NO MATCH: $line"; } }
Output:
MATCH: MyName='Custom' NO MATCH: MyName!='Custom'
-- Ken
In reply to Re: Match Text with Single Quotes
by kcott
in thread Match Text with Single Quotes
by JLowstetter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |