Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substitution: "\p{Cntrl}" - "\P{Print}"

Until now I use these two substitutions before printing "$string" to the terminal.

$string =~ s/\p{Space}/ /g;
$string =~ s/\p{Cntrl}//g;

Is there something that I should consider, when I replace the first two substitutions with the following two?

$string =~ s/\p{Space}/ /g;
$string =~ s/\P{Print}//g;
like image 610
sid_com Avatar asked Dec 29 '25 09:12

sid_com


1 Answers

See this question. There are two code points that are neither control nor printable characters: U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR. But both of them are space characters, so your two substitutions should be equivalent.

like image 141
nwellnhof Avatar answered Dec 31 '25 00:12

nwellnhof



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!