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

Re: ASCII to HTML

by little_mistress (Monk)
on Apr 05, 2000 at 01:58 UTC ( [id://6882]=note: print w/replies, xml ) Need Help??


in reply to ASCII to HTML

Well both examples create an odd thing:
<br> FOO<br> BAR<p><br> <br> BAZ<p><br> <br>

notice the extra break tags? where as a set of expressions will do the job like this:

$text = <<TEXT; FOO BAR BAZ TEXT $text =~s/\n{2,2}/<p>/g; $text =~s/\n{1,1}/<br>/g; $text =~ s/</\n</g; $text =~ s/>/>\n/g; print $text;

gives us this result

FOO <br> BAR <p> BAZ <br>
which i think is a little more of what you are looking for. I would suggest looking at the Regular Expressions book by O'Reilly. I left out some optimizations so you could go hunting for them.

take care

little_mistress@mainhall.com

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-16 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found