in reply to regex in html
You are correcly using the 's' modifier for your regex, but instead of using s///, use m// and capture $1 in another variable. The trick is, you have to catch $1 in array context:undef $/; $current = <DATA>; $start = '<!---CURCON-->'; $end = '<!---END CURCON-->'; my ($match) = $current =~ m/$start(.*)$end/s; print $match; __DATA__ stuff i don't want <!---CURCON--> stuff i do want <!---END CURCON--> more stuff i don't want
else $match will be equal to the number of matches found.my ($match) = $current =~ m/$start(.*)$end/s; # note the parens around + $match
Now $match will contain a newline at the beginning as well as one at the end:
Jeff$match =~ tr/\n//d; # or $match =~ s/\n//g;
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex in html
by cLive ;-) (Prior) on Apr 02, 2001 at 04:33 UTC | |
by jeffa (Bishop) on Apr 02, 2001 at 17:29 UTC |