Replacing multiple lines with a single line.

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Ed
Posts: 103
Joined: Tue Mar 04, 2003 9:09 am
Location: Devon, UK

Replacing multiple lines with a single line.

Post by Ed »

I want change multi-line statements to single lines - for example:

Code: Select all

WARNING( "<some text", param1,
    param2, param3,
    param4 );
to

Code: Select all

WARNING( "<some text", param1, param2, param3, param4 );
where the delimiters are WARNING and ;

any ideas?
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

This works for me on the sample provided, with a little housekeeping ;)

Code: Select all

Find ^((WARNING|\s+).+?,)\s\n
Replace $1
Why I need the \s before the \n is a mistery to me, perhaps Helios can shed some light on that?
And the housekeeping part would be

Code: Select all

Find ,\s+
Replace ,_
where _=space
You most likely will need to limit the above regex some more but I'm sure you get the idea. HTH
Then I open up and see
the person fumbling here is me
a different way to be
Ed
Posts: 103
Joined: Tue Mar 04, 2003 9:09 am
Location: Devon, UK

Post by Ed »

I think I wasn't clear enough. There are loads of other lines of code, many of which start with spaces.
I only want to join lines that start WARNING and end with ;
I think I left the trailing space in the example. It shouldn't be there.

Having said all that I used
^( *WARNING.+?,) *\r\n
replace with
$1

and this did the trick. So many thanks s-r
Post Reply