Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 712 Bytes

no-lookbehind-assertions-regexp.md

File metadata and controls

31 lines (21 loc) · 712 Bytes

disallow the use of lookbehind assertions((?<= ) and (?<! )) in regular expressions (no-lookbehind-assertions-regexp)

Regular expression lookbehind assertions are not supported by some browsers (such as Safari) and can cause unexpected errors.

Rule Details

This rule disallows the use of regular expression lookbehind assertions.

Examples

In the examples below, we will use the following configuration:

"rules": {
  "lookbehind-assertions/no-lookbehind-assertions-regexp": "error"
}

Examples of incorrect code:

let re = /(?<=ripe )orange/;
re = new RegExp('(?<=ripe )orange');

Examples of correct code:

let re = /\d+(?=%)/;
re = new RegExp('d+(?=%)');