in reply to Re^2: hex in regexp
in thread hex in regexp
Changing upper to ascii and using your string, I get:
$ perl -Mstrict -Mwarnings -E ' my $x = q{çe quil Y a Yå}; $x =~ s/([[:^ascii:]])/unpack q{H2}, $1/eg; say $x; ' c383c2a7e quil Y a Yc383c2a5
Check that you didn't make a typo when entering your code. If you are still having problems, please post your code - as it is, I can't reproduce your problem.
To wrap the codes in < and >, or any other characters, you can just concatenate the characters at the beginning and end of the hex code:
$ perl -Mstrict -Mwarnings -E ' my $x = q{çe quil Y a Yå}; $x =~ s/([[:^ascii:]])/q{<} . unpack(q{H2}, $1) . q{>}/eg; say $x; ' <c3><83><c2><a7>e quil Y a Y<c3><83><c2><a5>
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: hex in regexp
by shamanoff (Initiate) on May 22, 2012 at 21:09 UTC | |
|
Re^4: hex in regexp
by shamanoff (Initiate) on May 22, 2012 at 21:23 UTC |