Skip to content

Commit c7486d5

Browse files
committed
docs: add example with flags
1 parent 6fbf967 commit c7486d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ console.log(regExp)
5454

5555
## Usage
5656

57-
Every regular expression you create with the library should be wrapped in `createRegExp`.
57+
Every pattern you create with the library should be wrapped in `createRegExp`. It also takes a second argument, which is an array of flags.
58+
59+
```js
60+
import { createRegExp, global, multiline } from 'magic-regexp'
61+
createRegExp('string-to-match', [global, multiline])
62+
// you can also pass flags directly as strings
63+
createRegExp('string-to-match', ['g', 'm'])
64+
```
5865

5966
> **Note**
6067
> By default, all helpers from `magic-regexp` assume that input that is passed should be escaped - so no special RegExp characters apply. So `createRegExp('foo?\d')` will not match `food3` but only `foo?\d` exactly.

0 commit comments

Comments
 (0)