Skip to content

Commit 77ec36e

Browse files
committed
chore: update docs
1 parent ceb2083 commit 77ec36e

File tree

3 files changed

+45
-47
lines changed

3 files changed

+45
-47
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,30 @@ See [Regex Builder API doc](./docs/API.md#builder) for more info.
104104

105105
### Regex Constructs
106106

107-
| Construct | Regex Syntax | Notes |
108-
| ------------------- | ------------ | ------------------------------- |
109-
| `capture(...)` | `(...)` | Create a capture group |
110-
| `choiceOf(x, y, z)` | `x\|y\|z` | Match one of provided sequences |
107+
| Construct | Regex Syntax | Notes |
108+
| ------------------------- | ------------ | ------------------------------------------- |
109+
| `choiceOf(x, y, z)` | `x\|y\|z` | Match one of provided sequences |
110+
| `capture(...)` | `(...)` | Create a capture group |
111+
| `lookahead(...)` | `(?=...)` | Match subsequent text without consuming it |
112+
| `negativeLookhead(...)` | `(?!...)` | Reject subsequent text without consuming it |
113+
| `lookbehind(...)` | `(?<=...)` | Match preceding text without consuming it |
114+
| `negativeLookbehind(...)` | `(?<!...)` | Reject preceding text without consuming it |
111115

112116
See [Regex Constructs API doc](./docs/API.md#constructs) for more info.
113117

118+
> [!NOTE]
119+
> TS Regex Builder does not have a construct for non-capturing groups. Such groups are implicitly added when required.
120+
114121
### Quantifiers
115122

116-
| Quantifier | Regex Syntax | Description |
117-
| ----------------------------------------------- | ------------ | -------------------------------------------------------------- |
118-
| `zeroOrMore(x)` | `x*` | Zero or more occurence of a pattern |
119-
| `oneOrMore(x)` | `x+` | One or more occurence of a pattern |
120-
| `optional(x)` | `x?` | Zero or one occurence of a pattern |
121-
| `repeat(x, n)` | `x{n}` | Pattern repeats exact number of times |
122-
| `repeat(x, { min: n, })` | `x{n,}` | Pattern repeats at least given number of times |
123-
| `repeat(x, { min: n, max: n2 })` | `x{n1,n2}` | Pattern repeats between n1 and n2 number of times |
123+
| Quantifier | Regex Syntax | Description |
124+
| -------------------------------- | ------------ | ------------------------------------------------- |
125+
| `zeroOrMore(x)` | `x*` | Zero or more occurence of a pattern |
126+
| `oneOrMore(x)` | `x+` | One or more occurence of a pattern |
127+
| `optional(x)` | `x?` | Zero or one occurence of a pattern |
128+
| `repeat(x, n)` | `x{n}` | Pattern repeats exact number of times |
129+
| `repeat(x, { min: n, })` | `x{n,}` | Pattern repeats at least given number of times |
130+
| `repeat(x, { min: n, max: n2 })` | `x{n1,n2}` | Pattern repeats between n1 and n2 number of times |
124131

125132
See [Quantifiers API doc](./docs/API.md#quantifiers) for more info.
126133

docs/API.md

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,46 @@ It optionally accepts a list of regex flags:
4646

4747
These functions and objects represent available regex constructs.
4848

49-
### `capture()`
49+
### `choiceOf()`
5050

5151
```ts
52-
function capture(
53-
sequence: RegexSequence
54-
): Capture
52+
function choiceOf(
53+
...alternatives: RegexSequence[]
54+
): ChoiceOf {
5555
```
5656
57-
Regex syntax: `(...)`.
57+
Regex syntax: `a|b|c`.
5858
59-
Captures, also known as capturing groups, extract and store parts of the matched string for later use.
59+
The `choiceOf` (disjunction) construct matches one out of several possible sequences. It functions similarly to a logical OR operator in programming. It can match simple string options as well as complex patterns.
60+
61+
Example: `choiceOf("color", "colour")` matches either `color` or `colour` pattern.
6062
61-
### `nonCaptureGroup()`
63+
### `capture()`
6264
6365
```ts
64-
function nonCaptureGroup(
66+
function capture(
6567
sequence: RegexSequence
66-
): NonCaptureGroup
68+
): Capture
6769
```
6870

69-
Regex syntax: `(?:...)`.
71+
Regex syntax: `(...)`.
72+
73+
Captures, also known as capturing groups, extract and store parts of the matched string for later use.
7074

71-
Groups multiple tokens together without creating a capture group.
75+
> [!NOTE]
76+
> TS Regex Builder does not have a construct for non-capturing groups. Such groups are implicitly added when required. E.g., `zeroOrMore(["abc"])` is encoded as `(?:abc)+`.
7277

73-
### `positiveLookahead()`
78+
### `lookahead()`
7479

7580
```ts
76-
function positiveLookahead(
81+
function lookahead(
7782
sequence: RegexSequence
78-
): PositiveLookahead
83+
): Lookahead
7984
```
8085

8186
Regex syntax: `(?=...)`.
8287

83-
Matches a group after the main expression without including it in the result.
88+
Allows for conditional matching by checking for subsequent patterns in regexes without consuming them.
8489

8590
### `negativeLookahead()`
8691

@@ -92,19 +97,19 @@ function negativeLookahead(
9297

9398
Regex syntax: `(?!...)`.
9499

95-
Specifies a group that can not match after the main expression (if it matches, the result is discarded).
100+
Allows for matches to be rejected if a specified subsequent pattern is present, without consuming any characters.
96101

97-
### `positiveLookbehind()`
102+
### `lookbehind()`
98103

99104
```ts
100-
function positiveLookahead(
105+
function lookbehind(
101106
sequence: RegexSequence
102-
): PositiveLookahead
107+
): Lookahead
103108
```
104109

105110
Regex syntax: `(?<=...)`.
106111

107-
Matches a group before the main expression without including it in the result.
112+
Allows for conditional matching by checking for preceeding patterns in regexes without consuming them.
108113

109114
### `negativeLookbehind()`
110115

@@ -116,20 +121,7 @@ function negativeLookahead(
116121

117122
Regex syntax: `(?<!...)`.
118123

119-
Specifies a group that can not match before the main expression (if it matches, the result is discarded).
120-
### `choiceOf()`
121-
122-
```ts
123-
function choiceOf(
124-
...alternatives: RegexSequence[]
125-
): ChoiceOf {
126-
```
127-
128-
Regex syntax: `a|b|c`.
129-
130-
The `choiceOf` (disjunction) construct matches one out of several possible sequences. It functions similarly to a logical OR operator in programming. It can match simple string options as well as complex patterns.
131-
132-
Example: `choiceOf("color", "colour")` matches either `color` or `colour` pattern.
124+
Allows for matches to be rejected if a specified preceeding pattern is present, without consuming any characters.
133125

134126
## Quantifiers
135127

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ export { lookahead } from './constructs/lookahead';
2222
export { lookbehind } from './constructs/lookbehind';
2323
export { negativeLookahead } from './constructs/negative-lookahead';
2424
export { negativeLookbehind } from './constructs/negative-lookbehind';
25-
export { nonCaptureGroup } from './constructs/non-capture-group';
2625
export { oneOrMore, optional, zeroOrMore } from './constructs/quantifiers';
2726
export { repeat } from './constructs/repeat';

0 commit comments

Comments
 (0)