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
|`word`|`\w`| Word character: letter, digit, underscore |
134
-
|`digit`|`\d`| Digit character: 0 to 9 |
135
-
|`whitespace`|`\s`| Whitespace character: space, tab, line break, ... |
136
-
|`anyOf('abc')`|`[abc]`| Any of provided characters |
137
-
|`charRange('a', 'z')`|`[a-z]`| Character in a range |
138
-
|`charClass(...)`|`[...]`| Union of multiple character classes |
139
-
|`negated(...)`|`[^...]`| Negation of a given character class |
140
-
|`char(...)`|`\uXXXX`| Character specified given Unicode code point |
141
-
|`unicodeProperty(...)`|`\p{...}`| Characters with given Unicode property |
142
-
143
-
144
-
See [Character Classes API doc](https://callstack.github.io/ts-regex-builder/api/character-classes) and [Unicode API doc](https://callstack.github.io/ts-regex-builder/api/unicode) for more info.
145
-
146
128
### Assertions
147
129
148
130
| Assertion | Regex Syntax | Description |
@@ -151,12 +133,30 @@ See [Character Classes API doc](https://callstack.github.io/ts-regex-builder/api
151
133
|`endOfString`|`$`| Match the end of the string (or the end of a line in multiline mode) |
152
134
|`wordBoundary`|`\b`| Match the start or end of a word without consuming characters |
153
135
|`lookahead(...)`|`(?=...)`| Match subsequent text without consuming it |
154
-
|`negativeLookhead(...)`|`(?!...)`| Reject subsequent text without consuming it |
136
+
|`negativeLookahead(...)`|`(?!...)`| Reject subsequent text without consuming it |
155
137
|`lookbehind(...)`|`(?<=...)`| Match preceding text without consuming it |
156
138
|`negativeLookbehind(...)`|`(?<!...)`| Reject preceding text without consuming it |
157
139
158
140
See [Assertions API doc](https://callstack.github.io/ts-regex-builder/api/assertions) for more info.
159
141
142
+
### Character classes
143
+
144
+
> [!TIP]
145
+
> You may also use inline regexes for specifying character classes, as they offer a concise yet readable syntax. For example, `/[a-z0-9_]/`.
|`word`|`\w`| Word character: letter, digit, underscore |
151
+
|`digit`|`\d`| Digit character: 0 to 9 |
152
+
|`whitespace`|`\s`| Whitespace character: space, tab, line break, ... |
153
+
|`anyOf('abc')`|`[abc]`| Any of provided characters |
154
+
|`charRange('a', 'z')`|`[a-z]`| Character in a range |
155
+
|`charClass(...)`|`[...]`| Union of multiple character classes |
156
+
|`negated(...)`|`[^...]`| Negation of a given character class |
157
+
158
+
See [Character Classes API doc](https://callstack.github.io/ts-regex-builder/api/character-classes) and [Unicode API doc](https://callstack.github.io/ts-regex-builder/api/unicode) for more info.
159
+
160
160
## Examples
161
161
162
162
See [Examples](https://callstack.github.io/ts-regex-builder/examples).
@@ -185,8 +185,6 @@ TS Regex Builder is inspired by [Swift Regex Builder API](https://developer.appl
Copy file name to clipboardExpand all lines: src/constructs/anchors.ts
+12
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,32 @@
1
1
importtype{EncodedRegex}from'../types';
2
2
3
+
/**
4
+
* Start of string anchor. Matches the start of of string. In `multiline` mode, also matches immediately following a newline.
5
+
*/
3
6
exportconststartOfString: EncodedRegex={
4
7
precedence: 'atom',
5
8
pattern: '^',
6
9
};
7
10
11
+
/**
12
+
* End of string anchor. Matches the end of a string. In `multiline` mode, also matches immediately preceding a newline.
13
+
*/
8
14
exportconstendOfString: EncodedRegex={
9
15
precedence: 'atom',
10
16
pattern: '$',
11
17
};
12
18
19
+
/**
20
+
* Word boundary anchor. Matches the position where one side is a word character (alphanumeric or underscore) and the other side is a non-word character (anything else).
21
+
*/
13
22
exportconstwordBoundary: EncodedRegex={
14
23
precedence: 'atom',
15
24
pattern: '\\b',
16
25
};
17
26
27
+
/**
28
+
* Non-word boundary anchor. Matches the position where both sides are word characters.
Copy file name to clipboardExpand all lines: website/docs/api/unicode.md
+1
Original file line number
Diff line number
Diff line change
@@ -33,5 +33,6 @@ Unicode character property escape matching a set of characters specified by a Un
33
33
Regex syntax: `\p{Property}` or `\p{Property=Value}`
34
34
35
35
See:
36
+
36
37
-[MDN: Unicode character class escape](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape)
0 commit comments