File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -59,19 +59,22 @@ With `.not()` (aka. regex complement) this is easy:
59
59
``` typescript
60
60
import { RB } from ' @gruhn/regex-utils'
61
61
62
- const commentStart = RB (' /*' )
63
- const commentEnd = RB (' */' )
64
- const commentInner = commentEnd .not ()
62
+ const commentInner = RB (/ ^ . * $ / ) // any string
63
+ .concat (' */' ) // followed by comment end marker
64
+ .concat (/ ^ . * $ / ) // followed by any string
65
+ .not () // negate whole pattern
65
66
66
- const commentRegex = commentStart .concat (commentInner ).concat (commentEnd )
67
+ const commentRegex = RB (' /*' )
68
+ .concat (commentInner )
69
+ .concat (' */' )
67
70
```
68
71
69
72
With ` .toRegExp() ` we can convert back to a native JavaScript regex:
70
73
``` typescript
71
74
commentRegex .toRegExp ()
72
75
```
73
76
```
74
- /^(\/\*((\*{2}(\/?\*)*(\/ [^\*]|[^\*\/])|\*(\/.| [^\*\/])| [^\*])(\*(\/?\*)*(\/[^\*]|[^\*\/])|[^\*])*\*(\/?\*)*\/|\*(\*(\/?\*)*\/|\/)) )$/
77
+ /^(\/\*[^\*]*\*( [^\*\/][^\*]*\*|\*)*\/ )$/
75
78
```
76
79
77
80
### Password Regex using Intersections
You can’t perform that action at this time.
0 commit comments