I'd apply two s/// conditionally. Assuming that the words going into section or h1 tags are all on a line:
while(<DATA>) { s!(?<=<sb>)<s(\d+)>(.*)!<h$1>$2</h$1>! or s!<s(\d+)>(.*)!<section$1>$2</section$1>!; print } __DATA__ <s1>King of England JAMES, by the Grace of God, King of England, Scotland, France and Irel +and, Defender of the Faith... ... This first selection was written in England to establish the colony of + Virginia <sb><s1>Rights of Landowners We, greatly commending, and graciously accepting of, their Desires for + the Furtherance</sb>
outputs
<section1>King of England</section1> JAMES, by the Grace of God, King of England, Scotland, France and Irel +and, Defender of the Faith... ... This first selection was written in England to establish the colony of + Virginia <sb><h1>Rights of Landowners</h1> We, greatly commending, and graciously accepting of, their Desires for + the Furtherance</sb>
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Help in regex
by shmem
in thread Help in regex
by rsriram
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |