maha has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
i want to close </book-part> tag before the next chapter tag beginning
e.g
<book-part book-part-type="chapter" book-part-number="\d+" id="chapter\d+">its a beginning tag of each chapter.
"</book-part>" should close before next chapter's opening tag,(i.e)</book-part> is an ending tag of each chapter
plz give some suggestion, thank u monks
i try below code but i does't show any changes
if($str =~ /<book-part book-part-type="chapter" id="chapter\d+">((?:(? +!<\/?book-part book-part-type="chapter" id="chapter\d+">).)*)(?=<book +-part book-part-type="chapter" id="chapter\d+">)/sgi) { $str .="<book-part>"; }
my output generate in below
</book-part> <book-part book-part-type="chapter" book-part-number="2" id="chapter2" +>
"</book-part>" this is first chapter's closing and "<book-part book-part-type="chapter" book-part-number="2" id="chapter2">" this is second chapter opening
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML tag closing
by tobyink (Canon) on Jan 06, 2012 at 07:14 UTC | |
|
Re: XML tag closing (naive way)
by tye (Sage) on Jan 06, 2012 at 06:09 UTC | |
by maha (Novice) on Jan 06, 2012 at 10:34 UTC | |
by maha (Novice) on Jan 06, 2012 at 09:10 UTC | |
by cavac (Prior) on Jan 07, 2012 at 13:01 UTC |