in reply to Regex Question
I've got text some text with line breaks. I want to strip all line breaks, unless there are two next to each other.
What do you want to happen if there's more than 2? This will remove single breaks, but reduce any greater number to a single one:
If you want to reduce multiples to 1 less (i.e. \n\n\n would become \n\n) then just put the * inside the brackets:$text =~ s/(\n)*\n/$1/g;
$text =~ s/(\n*)\n/$1/g;
Tony
|
|---|