So I'm trying to do a number of regex across a file, which seems straight forward enough.
However, when I try to regex a string with characters \ and " my regex fails to find the string.
E.g. the following can be found
START
But the following cannot
\"START\"
Here's the pertinent code
$findstart = "\\\"START\\\"";
$replacestart = "replace string";
$infile =~ s/$findstart/$findstart\n$replacestart/g;
I've tried
$findstart = '\"START\"';
However, when I enter it in like:
$infile =~ s/\"START\"/$findstart\n$replacestart/g;
Then it works. Does anyone know what I'm doing wrong?
Thanks!!!
However, when I try to regex a string with characters \ and " my regex fails to find the string.
E.g. the following can be found
START
But the following cannot
\"START\"
Here's the pertinent code
$findstart = "\\\"START\\\"";
$replacestart = "replace string";
$infile =~ s/$findstart/$findstart\n$replacestart/g;
I've tried
$findstart = '\"START\"';
However, when I enter it in like:
$infile =~ s/\"START\"/$findstart\n$replacestart/g;
Then it works. Does anyone know what I'm doing wrong?
Thanks!!!