Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As they already said, there's a Module to do this ... or several (TMTOWTDI) ... but there's also a really cute expression that's worth grokking-in-fullness, even if you should use the module instead, since it's a lovely example of s///g and s///e together.

From Effective Perl Programming (Hall with Schwartz, 0-201-41975-0 not linked to Fatbrain, please support your local meatspace bookstore),

$_ = "a%5eb"; s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
which also says only one paragraph later
use URI::Escape; $_ = uri_unescape "a%5eb";
Both will result in $_ eq "a^b".

and Yes, it will handle "9%25EA" correctly, tranforming it to "9%EA" and not eating the output %. See s///g. (What's 9%EA? maybe fair share for 11-way split, less crumbs.)

-- Bill / n1vux


In reply to Re: Regex to cange HTML %?? to char(0x??); by Anonymous Monk
in thread Regex to cange HTML %?? to char(0x??); by Buckaroo Buddha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found