Hello,
I have some data coming into a system with markup that I need to
reinterpret into HTML. I have a feeling I'm making this problem more
complex than it needs to be.
The beginning and ending markup are the same. So <I>text<I> would
become <I>text</I> in HTML. A single line can have more than one of
these italicized words, for example.
So this doesn't work:
s/(\<I\>)(.*)(\<I\>)/$1$2\<\/I\>/g
because .* matches anything in between and only the last one is
considered. <I>text<I>blahblah<I>text<I> becomes
<I>textblahblahtext</I>.
I would like it to match every second <I> and replace it with </I>, no
matter how many occurrences in a line. Am I on the right track with
something like this?:
for $line (@descriptions) {
...
$count = 0;
$line =~
s{
\<I\>
}{
if (++$count==2){
\<\/I\>
}
else {
\<I\>
}
}gex;
...
}
which gives me the following error:
Unterminated <> operator at program.pl line 48.
Line 48 is }{
So I have the syntax wrong, at the very least.
Should I be thinking more in terms of some sort of lookahead?
Any hints as to how to approach this will be appreciated.
-Chris Cosner
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>