You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These regex patterns are **better than most VS Code or VSCodium extensions** for removing comments, as they allow for more control and precision.
3
+
4
+
5
+
6
+
## 1. Full-Line Comments
7
+
8
+
### Regex Pattern:
9
+
```regex
10
+
^\s*#.*$
11
+
```
12
+
13
+
### Description:
14
+
Deletes entire lines that contain only comments, including those with leading spaces.
15
+
16
+
---
17
+
18
+
## 2. Trailing (Inline) Comments After Code
19
+
20
+
### Regex Pattern:
21
+
```regex
22
+
(?<=\S)\s{2,}#.*$
23
+
```
24
+
25
+
### Description:
26
+
Deletes comments that appear after code, but only if there are **at least two spaces** before the `#`.
27
+
28
+
---
29
+
30
+
## 3. Strict Docstring Matching (One-Liner)
31
+
### Regex Pattern:
32
+
```
33
+
"""[^"]+"""
34
+
```
35
+
Description:
36
+
Matches strict one-line docstrings enclosed by triple quotes (""") in function definitions. This ensures it doesn't accidentally match strings or comments.
0 commit comments