my input :
this simple text test purpose ascii text 12345678910-=[];'#/.,- new regexxx ! " £ $ % ^ & * ( ) _ + { }~@:<>?|asdf –jkll
now using json decode input data decodes(html type of response ex:  ,\x{a3},> etc...) follows:
this simple text test purpose ascii text12345678910-=[];\'#/.,\\-with new regexxx!\"\u00a3$%^&*()_+{}~@:<>?|
asdf \u2013jkll
"
now sending decoded data program replace unicode(utf-8) , other non-ascii characters space/or printable characters(i mean want print ascii range characters) so, tried of following in perl.
use strict; use warnings; use json; use lwp::useragent; use utf8; #due security reasons not mentioning url,hope u understand $resref = sendhttprequest($someurlrequest); $string = $resref->decoded_content;#i used json decode decode content $string = transalte_replace($string); sub transalte_replace { $string = shift; for($string) { s/\\u[0-9]+/1-/g; s/\\u[a-za-z0-9\+]*/2-/g; s/\\x\{[a-za-z0-9]*\}/3-/g; s/[^\p{ascii}]/-/g; s/[^\u0000-\u007f]+/replace1/g; s/[^\x00-\x7f]+/rep/g; s/[^\p{ascii}]/-/g; s/[^a-za-z0-9\.,\?'""!@#\$%\^&\*\(\)-_=\+;:\<\>\/\\\|\}\{\[\]`\~]+/y/g; #s/[£]//g; s/[^\x20-\x7e]+/replace3/g; #s/\\u[0-9]+/2-/g; #s/\\x[a-z0-9]+/3-/g; #s/[^\x00-\x7f]/4-/g; } }
the output still is:
"this simple text test purpose ascii text12345678910-=[];'#/.,\-with new regexxx!\"\x{a3}\$%^&*()_+{}~\@:?|asdf \x{2013}jkll";
i working on windows environment, want ascii range characters,numbers , symbols , nothing else.please help
s/[^\p{ascii}]/-/g
is equivalent to
s/[^\x00-\x7f]/-/g
so couldn't possibly leave ac
, a3
unchanged.
use strict; use warnings; use utf8; # source code encoded using utf-8. use open ':std', ':encoding(utf-8)'; # terminal produces/expects utf-8. use feature qw( ); $string = q{¬`\\|!"£$%^&*()_+{}:@~<>?,./;'#[]=-0987654321:-+><}; sprintf '%1$vx %1$s', $string; $string =~ s/[^\p{ascii}]/-/g; sprintf '%1$vx %1$s', $string;
output:
$ perl a.pl ac.60.5c.7c.21.22.a3.24.25.[...] ¬`\|!"£$%^&*()_+{}:@~<>?,./;'#[]=-0987654321:-+>< 2d.60.5c.7c.21.22.2d.24.25.[...] -`\|!"-$%^&*()_+{}:@~<>?,./;'#[]=-0987654321:-+>< ^^ ^^ ^ ^
did apply s///
operator right variable?
Comments
Post a Comment