Hai Vautrin,

Thanks for ur kind reply.

Actually im working in an concern as text file to sgml/xml/html conversion and validation programmer(Trainee). what i asked as an example is not only for HTML but for all the mark up languages.

secondly, Im working with the plain text files with some short tags applied in them to convert them into some markup languages(XML or SGML) under some dtd specification.

input:

[[tx]][[nm]]Murugesan[[/nm]]is trainee perl programmer.[[/tx]] [[tx1]][[nm]]Murugesan[[/nm]]is trainee perl programmer.[[/tx1]]

output:

<customer><name type="rrd">Murugesan</name> is trainee perl programmer +</customer> <vendor><name type="integra">Murugesan</name> is trainee perl programm +er</vendor>

my next doubt is, while im converting above input text inside some short tag(nesting), what im doing now is im using the subroutines in regular expression to convert them into the output format as mentioned in my below code.

s/\[\[tx\]\](.*?)\[\[\/tx\]\]/'<customer>'.&txt($1).'<\/customer>'/egs +i; sub txt{ my $a=$_[0]; $a=~s/\[\[nm\]\](.*?)\[\[\/nm\]\]/<name type="rrd">$1<\/name>/gsi; return $a; }

In the above coding i have just done for single level nesting of name. some times more number of nestings are present. Is this method of using subroutines inside the regular expression which lead to nested subroutines is o.k or is there any other effecient method available.


In reply to Re: Re: nested tag matching by Anonymous Monk
in thread nested tag matching by murugu

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.