Skip to content

Commit cc18823

Browse files
committed
minor fixes
1 parent 6989312 commit cc18823

File tree

1 file changed

+4
-4
lines changed
  • 9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags

1 file changed

+4
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
Opening tag is `pattern:\[(b|url|quote)\]`.
2+
Opening tag is `pattern:\[(b|url|quote)]`.
33

44
Then to find everything till the closing tag -- let's use the pattern `pattern:.*?` with flag `pattern:s` to match any character including the newline and then add a backreference to the closing tag.
55

6-
The full pattern: `pattern:\[(b|url|quote)\].*?\[/\1\]`.
6+
The full pattern: `pattern:\[(b|url|quote)\].*?\[/\1]`.
77

88
In action:
99

1010
```js run
11-
let regexp = /\[(b|url|quote)\].*?\[\/\1\]/gs;
11+
let regexp = /\[(b|url|quote)].*?\[\/\1]/gs;
1212

1313
let str = `
1414
[b]hello![/b]
@@ -20,4 +20,4 @@ let str = `
2020
alert( str.match(regexp) ); // [b]hello![/b],[quote][url]http://google.com[/url][/quote]
2121
```
2222

23-
Please note that besides escaping `pattern:[` and `pattern:]`, we had to escape a slash for the closing tag `pattern:[\/\1]`, because normally the slash closes the pattern.
23+
Please note that besides escaping `pattern:[`, we had to escape a slash for the closing tag `pattern:[\/\1]`, because normally the slash closes the pattern.

0 commit comments

Comments
 (0)