rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have a text file where the start and end of List will be marked with <list> and </list>. I want to code every paragraphs appearing inside this to be tagged as <item> and </item>
For example
Input format
The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog. <list>The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</list> The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog.
Output should be:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog. <list><item>The quick brown fox jumps over the lazy dog.</item> <item>The quick brown fox jumps over the lazy dog.</item> <item>The quick brown fox jumps over the lazy dog.</item></list> The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog.
Can anyone give a regex pattern to replace this?
Sriram
20060622 Janitored by Corion: Added code tags around data, as per Writeup Formatting Tips
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex to replace a particular part of content
by GrandFather (Saint) on Jun 22, 2006 at 11:18 UTC | |
by johngg (Canon) on Jun 23, 2006 at 14:22 UTC | |
by GrandFather (Saint) on Jun 23, 2006 at 18:10 UTC | |
by johngg (Canon) on Jun 23, 2006 at 18:57 UTC | |
Re: Regex to replace a particular part of content
by shmem (Chancellor) on Jun 22, 2006 at 11:26 UTC | |
Re: Regex to replace a particular part of content
by reneeb (Chaplain) on Jun 22, 2006 at 11:25 UTC | |
Re: Regex to replace a particular part of content
by Moron (Curate) on Jun 22, 2006 at 11:47 UTC |
Back to
Seekers of Perl Wisdom