Page 1 of 1
Replacing multiple lines with a single line.
Posted: Wed Mar 30, 2005 2:57 pm
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?
Posted: Wed Mar 30, 2005 4:35 pm
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
Posted: Wed Mar 30, 2005 8:00 pm
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