Groups

Function
RegExp equivalent
Explanation

capture`foo` capture.exactly`foo` capture('foo')

(foo)

Wrap the given token in a capture group

captureAs`name` `foo` captureAs`name`.exactly`foo` captureAs('name')('foo')

(?<name>foo)

Wrap the given token in a named capture group

captureAs`name` `foo`.ref`name` capture`foo`.ref(1)

(?<name>foo)\k<name> (foo)\1

Supply a number to reference the capture group with that index. Supply a string to reference a named capture group.

group`foo` group.exactly`foo` group('foo')

(?:foo)

Wrap the given token in a non-capture group

ahead`foo` ahead.exactly`foo` ahead('foo')

(?=foo)

Wrap the given token in a positive lookahead

behind`foo` behind.exactly`foo` behind('foo')

(?<=foo)

Wrap the given token in a positive lookbehind

notAhead`foo` not.ahead`foo` notAhead.exactly`foo` notAhead('foo')

(?!foo)

Wrap the given token in a negative lookahead

notBehind`foo` not.behind`foo` notBehind.exactly`foo` notBehind('foo')

(?<!foo)

Wrap the given token in a negative lookbehind

oneOf`foo` `bar` oneOf(exactly`foo`, exactly`bar`) oneOf('foo', 'bar')

(?:foo|bar)

Match one in the provided list of options

Last updated