[Linux-disciples] A Perl regex question

Stephen R Laniel steve at laniels.org
Fri Oct 15 16:17:23 EDT 2004


I'd like to add a quick hack to a Blosxom plugin, such that
when people post comments to my site it'll convert double
carriage returns into <p>'s.

But not so fast: what if they post a comment containing
double carriage returns followed by their own <p> or some
other block-level tag? I'd like to be able to say "Replace
<cr><cr> with <cr><cr><p>, unless there's already a <p>
there." Something like this is a start:

s{^[^<]}{<p>\1}gsm

but that also excludes any lines that begin with '<',
whether or not that's a '<' at the beginning of an HTML tag.
Granted, solo '<'s are going to be rare, so maybe it's a
chance worth taking. But is there any way to get what I'm
looking for?

-- 
``The intolerance of the Republican base, therefore, is a
  reason to vote against *Democrats*. Wow, fake
  libertarianism doesn't get any more fake than that!''
 -http://shorl.com/gagruprekurisu



More information about the Linux-disciples mailing list