[英]How to remove a particular character from an entire row of a particular string using perl regex?
From this string pattern: 从此字符串模式:
"test A dkdkd荴kdklsl skldsls荴lksdkdk skdkd荴kdkls";
I am trying to remove this character 荴 from the entire row.. 我正在尝试从整行中删除此字符.。
I tried this solution but it only remove the 荴 at the end of the row and not if it contains more than occurrence of it on the same row: 我尝试了这种解决方案,但它只删除了行末尾的and,而不是如果它在同一行中所包含的内容多于此,则不会删除:
$removeU8374 =~ s/^(test A .*)\N{U+8374}/$1/;
I even tried this but still removed only one occurrence of it and not remove all occurrence of 荴 character from the entire row: 我什至尝试了此操作,但仍然只删除了一次,并且没有删除整行中所有出现的荴字符:
$removeU8374 =~ s/^(test A .*)\N{U+8374}/$1/g;
If you want to remove it everywhere, ignore the rest of the string in your substitution, eg. 如果要在任何地方删除它,请忽略替换字符串的其余部分,例如。
$removeU8374 =~ s/\N{U+8374}//g;
Otherwise, you can loop on your substitution until it no longer matches. 否则,您可以循环进行替换,直到不再匹配为止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.