RegExp pattern - extension syntax (Definition)

A Perl 5 capability for specifying anchors with look-ahead patterns.

Availability:

ECMAScript edition - 3

Positional anchors can be constructed using patterns. These are enclosed in grouping operators and commence with a question mark.

A logical negation is also possible. However the syntax for this uses the JavaScript convention of an exclamation mark (!) rather than the regular expression convention of a circumflex (^).

A positional anchor, marking the location immediately before a capital letter would look like this:

(?=[A-Z])

A positional anchor marking a location immediately before any non-capital letter would look like this:

(?![A-Z])

The second example uses the logical negation operator.

Note that these are positional anchors that behave like the ^ and $ which denote the start and end of a line. They do not select any characters.

See also:RegExp pattern - grouping, RegExp pattern - position, RegExp pattern - references

Cross-references:

ECMA 262 edition 3 - section - 15.10.1

ECMA 262 edition 3 - section - 15.10.2.7

ECMA 262 edition 3 - section - 15.10.2.14