Hello,
is it possible to replace all C++ comments (//) within a C-sourcecode with C comments (/* ... */) using Textpad regex?
(I'm using Textpad 5.2)
Thanks for any hint.
sergeant
Regex to replace C++ comment with C comment ?
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
gan
Yes you could search for:
and replace with:
But since the /*....*/ can span several lines this might not be the result you want.
Let's say you have the following lines:
Using the regex example above it will be like this:
The example given above there are 3 lines in a row which is comments only and then it would make more sense to start with /* before comment 1 and end with */ after comment 3 instead of starting and ending the comment for each line. Using regex i cannot see how this could be done though since the // is for a single line only.
I guess it would be better if regex could change it into this, but i don't think that is possible:
Code: Select all
//(.*)Code: Select all
/*\1*/Let's say you have the following lines:
Code: Select all
//comment 1
//comment 2
//comment 3
HKEY hk; //comment 4Code: Select all
/*comment 1*/
/*comment 2*/
/*comment 3*/
HKEY hk; /*comment 3*/I guess it would be better if regex could change it into this, but i don't think that is possible:
Code: Select all
/*comment 1
comment 2
comment 3*/
HKEY hk; /*comment 3*/