in reply to Re: Efficiency issues in text parsing
in thread replacing text in specific tags
Hope this helped.#!perl use strict; use warnings; { # braces for localization of $/ local $/ = '<p>'; # end of record is now <p> print scalar <DATA>; # first chunk contains everything before first <p> tag, just pri +nt for (<DATA>) { s@([\d\D]*?</p>)@ my $var = $1; $var =~ s!\n! !g; $var @e; # substitute newlines by spaces before the closing </p> tag print; } } __DATA__ This is to test. this is to test <p>This is to test. This is to test</p> <p>This is to test. This is to test</p> This is to test. this is to test
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Efficiency issues in text parsing
by texuser74 (Monk) on Aug 27, 2003 at 06:25 UTC | |
by CombatSquirrel (Hermit) on Aug 27, 2003 at 09:50 UTC | |
by Anonymous Monk on Sep 05, 2003 at 08:40 UTC | |
by CombatSquirrel (Hermit) on Sep 06, 2003 at 14:37 UTC | |
by texuser74 (Monk) on Sep 25, 2003 at 04:06 UTC | |
|