Does anyone know how translate the POSIX regexp (?<!X)A
in JS?
Find A only if not preceded by X.
Definition and Usage. The ?! n quantifier matches any string that is not followed by a specific string n. Tip: Use the ?= n quantifier to match any string that IS followed by a specific string n.
The Match-zero-or-more Operator ( * ) This operator repeats the smallest possible preceding regular expression as many times as necessary (including zero) to match the pattern. `*' represents this operator. For example, `o*' matches any string made up of zero or more `o' s.
[] denotes a character class. () denotes a capturing group. [a-z0-9] -- One character that is in the range of a-z OR 0-9.
RegExp ObjectA regular expression is a pattern of characters. The pattern is used to do pattern-matching "search-and-replace" functions on text. In JavaScript, a RegExp Object is a pattern with Properties and Methods.
Simply check for either the beginning (ergo there is no X) or that there is a non-X character.
(^|[^X])A
For more than one character, you could check for A
and then check the matched text for X followed by A, and discard the match if it matches the second pattern.
Short answer: you can't.
JavaScript's RegExp Object
does not support negative lookbehind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With