in reply to Re: close end tag
in thread close end tag
Can I replace '<' to '<' and '>' to '>' if it is not a HTML element? I have coded to replace < but not able to add >#!/usr/bin/perl while($line = <DATA>){ @valid_entities= ('<a>','<td>','<th>','<var>','<br>'); my %htmlenties = map { $_ =>1 } @valid_entities; $line =~ s/(<(\w+?)(>))/exists $htmlenties{$1} ? $1 : defined ($2) ? +"<$2$3" : '<'/eg; print $line; } __DATA__ <Hello>Hi...<BR>how r u<br>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: close end tag
by Anonymous Monk on Aug 27, 2009 at 07:12 UTC | |
by Anonymous Monk on Aug 27, 2009 at 08:51 UTC | |
by Anonymous Monk on Aug 27, 2009 at 09:07 UTC |