in reply to Regex Question

i think that you want something like:

$text =~ s/([^\n])\n{1}([^\n])/$1$2/g;

this should match exactly 1 newline which is surrounded by a non-newline character on either side. the {1} modifies the character before it & tells it that you have to match exactly 1. it's a pretty good thing to learn- basically, you do:
m/x{1,}/ if you want to match at least 1
m/x{1,5}/ if you want to match at least 1 and most 5, etc.

you should read the perlre page for more information.

update:

the above code, as merlyn pointed out, is wrong- you should use his example. but i still think that you should read the perlre page. (:

Replies are listed 'Best First'.
Re: Re: Regex Question
by merlyn (Sage) on Jan 08, 2001 at 00:08 UTC