Yetimwork Beyene
Yetimwork Beyene

Reputation: 249

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:

   $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;

Upvotes: 1

Views: 69

Answers (1)

Hasturkun
Hasturkun

Reputation: 36402

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.

Upvotes: 1

Related Questions