mirror of
https://github.com/pdemian/human2regex.git
synced 2025-05-15 20:10:19 -07:00
Update API.md
This commit is contained in:
parent
27f37c21eb
commit
5767619463
8
API.md
8
API.md
@ -132,17 +132,17 @@ export enum RegexDialect {
|
||||
}
|
||||
```
|
||||
|
||||
After choosing one, you should validate the regular expression. This may be skipped if and only if the input has already been validated before. The generator is not guaranteed to work unless there are no validation errors. The generator does no validation itself and may either return garbage output or crash.
|
||||
After choosing one, you should validate the regular expression. This may be skipped if and only if the input has already been validated before. For example, you may keep the `parse_result` around and generate it multiple times, only validating the first time. The generator is not guaranteed to work unless there are no validation errors. The generator does no validation itself and may either return garbage output or crash.
|
||||
|
||||
```typescript
|
||||
const validation_errors = parse_result.validate();
|
||||
const validation_errors = parse_result.validate(RegexDialect.JS);
|
||||
```
|
||||
|
||||
The result is a list of errors which is a `CommonError`. If there are no errors, you can call the `toRegex()` function to create a string representation of the regular expression. You can also call the `toRegExp()` function to create a `RegExp` expression used in Javascript
|
||||
|
||||
```typescript
|
||||
const my_regex_string = parse_result.toRegex(); // type is string
|
||||
const my_regex = parse_result.toRegExp(); // type is RegExp
|
||||
const my_regex_string = parse_result.toRegex(RegexDialect.JS); // type is string
|
||||
const my_regex = parse_result.toRegExp(RegexDialect.JS); // type is RegExp
|
||||
```
|
||||
|
||||
This will contain your regular expression.
|
||||
|
Loading…
x
Reference in New Issue
Block a user