简体   繁体   中英

Search and replace a string having special characters in a file using Perl

Search and replace a string in a file using Perl. I have a .txt file. where i need to search and replace a string. i code i have is working fine for string not having special characters.but for the string containing special characters like (?,=,:: ) is not working with this code.

Problem statement image

Code i am using and expected results

Use Perl's built-in function quotemeta to escape all special characters in your search string. See https://perldoc.perl.org/functions/quotemeta.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM