-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a666086
commit f59e6bf
Showing
10 changed files
with
139 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
id: assertions | ||
title: Assertions | ||
--- | ||
|
||
## Anchors | ||
|
||
Anchors are special characters or sequences that specify positions in the input string rather than matching specific characters. | ||
|
||
### Start and end of string | ||
|
||
```ts | ||
const startOfString: Anchor; | ||
const endOfString: Anchor; | ||
``` | ||
|
||
- `startOfString` anchor matches the start of a string (or line, if multiline mode is enabled). Regex syntax: `^`. | ||
- `endOfString` anchor matches the end of a string (or line, if multiline mode is enabled). Regex syntax: `$`. | ||
|
||
### Word boundary | ||
|
||
_This API was added in version 1.3.0._ | ||
|
||
```ts | ||
const wordBoundary: Anchor; | ||
const notWordBoundary: Anchor; | ||
``` | ||
|
||
- `wordBoundary` matches the positions where a word character is not followed or preceded by another word character, effectively indicating the start or end of a word. Regex syntax: `\b`. | ||
- `notWordBoundary` matches the positions where a word character is followed or preceded by another word character, indicating that it is not at the start or end of a word. Regex syntax: `\B`. | ||
|
||
Note: word characters are letters, digits, and underscore (`_`). Other special characters like `#`, `$`, etc are not considered word characters. | ||
|
||
## Lookarounds | ||
|
||
Lookarounds in regex are used for asserting that some pattern is or isn't followed or preceded by another pattern, without including the latter in the match. | ||
|
||
### `lookahead()` | ||
|
||
_This API was added in version 1.3.0._ | ||
|
||
```ts | ||
function lookahead(sequence: RegexSequence): Lookahead; | ||
``` | ||
|
||
Regex syntax: `(?=...)`. | ||
|
||
Allows for conditional matching by checking for subsequent patterns in regexes without consuming them. | ||
|
||
### `negativeLookahead()` | ||
|
||
_This API was added in version 1.3.0._ | ||
|
||
```ts | ||
function negativeLookahead(sequence: RegexSequence): NegativeLookahead; | ||
``` | ||
|
||
Regex syntax: `(?!...)`. | ||
|
||
Allows for matches to be rejected if a specified subsequent pattern is present, without consuming any characters. | ||
|
||
### `lookbehind()` | ||
|
||
_This API was added in version 1.3.0._ | ||
|
||
```ts | ||
function lookbehind(sequence: RegexSequence): Lookahead; | ||
``` | ||
|
||
Regex syntax: `(?<=...)`. | ||
|
||
Allows for conditional matching by checking for preceeding patterns in regexes without consuming them. | ||
|
||
### `negativeLookbehind()` | ||
|
||
_This API was added in version 1.3.0._ | ||
|
||
```ts | ||
function negativeLookahead(sequence: RegexSequence): NegativeLookahead; | ||
``` | ||
|
||
Regex syntax: `(?<!...)`. | ||
|
||
Allows for matches to be rejected if a specified preceeding pattern is present, without consuming any characters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
id: builder | ||
title: Builder | ||
sidebar_position: 2 | ||
--- | ||
|
||
### `buildRegExp()` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters