Skip to content

Commit 71f02c9

Browse files
authored
feat: support s and d flag (#12)
- `s` means dotAll - `d` flag is just ignored
1 parent 8ef23ca commit 71f02c9

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

src/regexp-parse.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const REGEXP_LITERAL_PATTERN = /^\/(.*)\/([guimy]*)$/;
1+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags
2+
const REGEXP_LITERAL_PATTERN = /^\/(.*)\/([guimysd]*)$/;
23
export const parseRegExpString = (str: string): { source: string; flagString: string } | null => {
34
const result = str.match(REGEXP_LITERAL_PATTERN);
45
if (!result) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"/.+/s"
3+
]
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
2
3+
3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
- match text: **1
3+
2
4+
3
5+
**
6+
- captures: **[]**
7+
- startIndex: **0**
8+
- endIndex: **6**
9+
10+
```
11+
**1
12+
2
13+
3
14+
**
15+
```
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"match": "1\n2\n3\n",
4+
"captures": [],
5+
"startIndex": 0,
6+
"endIndex": 6
7+
}
8+
]

0 commit comments

Comments
 (0)