I have become somewhat enamored of how text is parsed by POD for inline HTML elements, like B<a string> or I<a string>. I have gotten a regex to work for them, however I have not been able to figure out how to nest them such as I<B<a string>>. Here is what I have so far:

s/([A-Z]+)<(.+?)>/<\L$1\E>$2<\/\L$1\E>/g;

I have not gotten into adding ids, classes, styles, or other attributes yet.

Here is the list of tags I may use with this regex:

use strict; use warnings; while ( my $string = <DATA>) { $string =~ s/([A-Z]+)<(.+?)>/<\L$1\E>$2<\/\L$1\E>/g; print $string; } __DATA__ ABBR<a string> ACRONYM<a string> B<a string> BIG<a string> CITE<a string> CODE<a string> DFN<a string> EM<a string> I<a string> KBD<a string> SAMP<a string> SMALL<a string> SPAN<a string> STRONG<a string> SUB<a string> SUP<a string> TT<a string> VAR<a string> This is a B<string> which I want to I<parse> almost like EM<a POD>. CO +DE<Let's see if I can do it.>

Before you ask, yes, I looked for it (for about an hour) on CPAN to no avail.

Thanks in advance!

Have a cookie and a very nice day!
Lady Aleena

In reply to POD style regex for inline HTML elements by Lady_Aleena

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.