Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Regex to cange HTML %?? to char(0x??);

by TGI (Parson)
on Jun 19, 2001 at 23:56 UTC ( #89791=note: print w/replies, xml ) Need Help??


in reply to Re: Regex to cange HTML %?? to char(0x??);
in thread Regex to cange HTML %?? to char(0x??);

How about these?

# The above shrunk a bit. $str =~ s/%([0-9A-F][0-9A-F])/chr(hex($1))/ieg; # - or more cryptic $str =~ s/%([0-9A-F][0-9A-F])/sprintf("%1c",hex($1))/ieg;

Can anyone think of something that doesn't use hex?


TGI says moo

Update

Bill's post and Abigail's clever method taken together let us chop off another character or so:

s/%([0-9A-F]{2})/"chr 0x$1"/igee;

TGI - Syncretic Cretin

Replies are listed 'Best First'.
Re: Regex to cange HTML %?? to char(0x??);
by Abigail (Deacon) on Jun 20, 2001 at 02:31 UTC
    Can anyone think of something that doesn't use hex?
    s/%([0-9A-F][0-9A-F])/"chr 0x$1"/ieeg;

    -- Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89791]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2019-09-23 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (274 votes). Check out past polls.

    Notices?