-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathanchors.ts
38 lines (33 loc) · 1.01 KB
/
anchors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { EncodedRegex } from '../types';
/**
* Start of string anchor. Matches the start of of string. In `multiline` mode, also matches immediately following a newline.
*/
export const startOfString: EncodedRegex = {
precedence: 'atom',
pattern: '^',
};
/**
* End of string anchor. Matches the end of a string. In `multiline` mode, also matches immediately preceding a newline.
*/
export const endOfString: EncodedRegex = {
precedence: 'atom',
pattern: '$',
};
/**
* 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).
*/
export const wordBoundary: EncodedRegex = {
precedence: 'atom',
pattern: '\\b',
};
/**
* Non-word boundary anchor. Matches the position where both sides are word characters.
*/
export const nonWordBoundary: EncodedRegex = {
precedence: 'atom',
pattern: '\\B',
};
/**
* @deprecated Renamed to `nonWordBoundary`.
*/
export const notWordBoundary = nonWordBoundary;