I would like to use Notepad++ to search a javascript file or a html file containing some javascript and replace all single line comments with a multiline style comment.
For example // some comment goes here to be replaced with /* some comment goes here */
Using Notepad++ search and replace with Regular Expression selected with (//.*)(\r\n) for search and \/*\1\*/\r\n kinda works.
Problems:
- It only finds
// some comment goes hereif there is at least one space before the // it will not find it if there is a tab before it, or at the start of a line or if there is a letter/number before it. I could workaround that by first doing a global non regular expression search replace to replace all occurrences of//withspace // // some comment goes hereis replaced with/*// some comment goes here*/that is the two forward slashes are not replaced. I can workaround this afterwards by doing a global non regular expression search to replace all occurrences of/*//with/*.- The javascript may be in a html file, in which case somewhere in the file there is likely to be something like
http://msdn.microsoft.com/clearly I would not like this to be replaced withhttp:/*msdn.microsoft.com/*/I could workaround this in advance by replacing all://with say:/ZZZ/where ZZZ is some escaping method and then afterwards replacing:/ZZZ/with:// - There will be problems with the likes of
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">I guess that I will have to look after these manually.
This is not really a Notepad++ problem. I am sure that I would have the same difficulties using any regular search and replace system.
All suggestions gratefully received.
Thank you for taking the time to read this


myString = ' // ';?