Regular expression and tags

software development


I’m having a tough time with a regular expression. My string is a chunk of html where somethimes occurs multilple times in a row and I want to replace that with a single occurance.
I was heading in this direction, but it doesn’t work in perl:



It works for me. Perhaps you overlooked something: newlines

$s = ‘’; # no newline.
$t = ‘\n’; # newline.

()+ would only match $s of course.

Though you might want to match on whitespace instead of a newline.

And don’t forget checking if the newline is CR, LF, or CR+LF.

:cool: [color=#6600CC]Atropos[/color] |