Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Firstly, the other entry you got, pointing you at HTML::Entities, is without a doubt the right way, if you are looking to solve the problem. On the other hand, you have looked at it, and rejected it for good reason (which here includes "because I already did it that way and want to try doing it other ways as well"), some advice on how to do it more or less the same way, but better...

s(&#(.*?);){ code goes here }eg;
is how I'd write that. The change to (.*?) instead of ([^;]+) is a matter of asthetics, and a somewhat contriversial one. It makes the regex somewhat slower, possibly, but it avoids repeating the exit condition. Putting on the /g is a matter of correctness -- consider <foo>. Note that you don't want to apply the regex to the same data in a loop -- consider &. The /e is to let the replacement thingy be code... what code I'm going to leave as an exercise to the reader.


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).


In reply to Re: NCR & CER to UTF-8 by theorbtwo
in thread NCR & CER to UTF-8 by vnpenguin

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 studying the Monastery: (2)
As of 2024-04-20 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found