in reply to Split tags and words nicely
#!/usr/local/bin/perl -l # use strict; use warnings; my $rxSplit = qr {(?x) (?<=[^<]) (?=[<]) | (?<=[>]) (?=[^<]) }; my $html = q{<tag ref=1>Start<tag ref=2>and more</tag>and end</tag>}; my @elems = split m{$rxSplit}, $html; print for @elems;
And the output.
<tag ref=1> Start <tag ref=2> and more </tag> and end </tag>
I hope this is of use.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split tags and words nicely
by ww (Archbishop) on Dec 28, 2006 at 18:56 UTC | |
by johngg (Canon) on Dec 28, 2006 at 19:57 UTC |