Tolgar
asked on
How to remove a string from a longer string in Perl?
Hi,
I would like to replace the following from a longer string.
/some/path/to/a/file/fileA .x is a dynamic file name and it is comes from $file in the code. Then rest is static.
Can you please tell me how I should write the regexp?
So, the pattern is like this:
I would like to replace the following from a longer string.
<td >
/some/path/to/a/file/fileA.x [<a href="special:read('/some/path/to/a/file/fileA.x')">Open</a>]
</td>
/some/path/to/a/file/fileA
Can you please tell me how I should write the regexp?
So, the pattern is like this:
<td >
$file [<a href="special:read('$file')">Open</a>]
</td>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@wilcoxon, won't any . characters in the string be treated as wildcards without escaping? (and other characters such as [](){}*+? may affect the pattern too)
ASKER
Perfect!!
Probably. If so, it's simple to just stick \Q at the beginning of the regex (don't remember if \Q$str will work or if \Q needs to be inside $str at the beginning).
\Q$str\E will quote metacharacters
Open in new window