With
Perl regular expression engine you could use the search string
^[\t ]*(?:/
[/*
].*)?$ together with
Filter lines and
Hide selected.
But you need to know that that hide lines feature is designed for hiding all lines containing a searched string. It is not designed for hiding all lines found by a regular expression which matches a string over more than one line. So it is not possible to hide a real multi-line block comment. If a regular expression search string matches strings over multiple lines, just the line on which found string starts is hidden by UltraEdit.
Explanation of the search expression:
^ ... beginning of line.
[\t ]* ...
tab or space 0 or more times.
(?:...
)? ... the expression in this
non capturing group 0 or 1 times.
/
[/*
] ... a slash and one more slash or an asterisk.
.* ...
any character except newline characters 0 or more times greedy (greedy = up to end of line in this case).
$ ... end of line.
A
Perl regular expression to remove with a Replace All all
- empty and blank lines,
- lines containing only a line comment, and
- block comments starting after 0 or more tabs/spaces of a line
would be
^(?:[\t ]*(?://
.*|/
\*
[\s\S]*?\*/
[\t ]*)?(?:\r?\n|\r|$))+
Note: Nested block comments are not supported by this expression nor by any regular expression engine. The matching of a block comment always ends on first
*/ independent on how many
/* are within already matched comment block.
^ ... beginning of line.
(?:...
)+ ... the expression in this outer
non capturing group 1 or more times greedy (greedy = as many lines or blocks as possible).
[\t ]* ...
tab or space 0 or more times.
(?:...
)? ... the expression in this inner
non capturing group 0 or 1 times.
//
.* ... two slashes and
any character except newline characters 0 or more times greedy (greedy = up to end of line in this case).
| ... OR
/
\*
[\s\S]*?\*/
[\t ]* ... a slash and an asterisk (must be
escaped here) and
any character including newline characters 0 or more times non-greedy (non-greedy = stop on first
*/ and not on last
*/) and an asterisk (again
escaped with a backslash) and
tab or space 0 or more times greedy (greedy = end of line in this case).
(?:...
) ... the expression in this second inner
non capturing group.
\r?\n|\r|$ ... a carriage return 0 or 1 times and a line-feed (DOS/UNIX) OR only a carriage return (MAC) OR end of line being interpreted here as end of file in case of last line in file does not end with a line termination.
Yes, Perl regular expressions are very powerful, but not easy to learn as it can be seen here especially on question mark having different meanings depending on context (non-capturing, 0 or 1 times, non-greedy).