Regex to match start of line and end of line for quick find and replace

Go To


Hey guys I've got a whole lot of HTML to format with

myString + "<somehtml></somehtml>";

Need 2 regex things, one to replace all new lines with myString + " and one to replace all end of lines with ";

Just using MyEclipse, Find and replace with regex enabled. Could anyone help me out?

2012-04-04 01:41
by Baconbeastnz


Individual regular expression engines may vary, but generally speaking, '^' will match the beginning of a line and '$' will match the end of a line.

2012-04-04 01:47
by Ariel
Need to put it in [^] thats throwing an error, sigh I dunno if this is possible - Baconbeastnz 2012-04-04 01:51
I've never used that particular flavor of Eclipse, but on vanilla eclipse, if you just search for '(^)' and replace with 'myString + "' (both without the outer single quotes when actually typing it in), you should get the desired effect. Also, this link shows how to access regex help for Eclipse - Ariel 2012-04-04 02:06