0
this.getRelativeStrengthIndexOverrides(value, /(?<=RSI14).*?(?=Over)/g, overrides);

method:

getRelativeStrengthIndexOverrides(name: string, regex: string | RegExp, overrides: any): [] {
..
}

It work fine with chrome but not in firefox. I am getting error

"SyntaxError: invalid regexp group"

Problem is with this: ?<= in regex

I don't understand why? What is different with this regex in chrome and FF. If I am checking this page, then it should work in firefox too.

http://kangax.github.io/compat-table/es2016plus/

mbrc
  • 3,523
  • 13
  • 40
  • 64
  • Can you give an example of the string you are searching in – Rob Kwasowski Dec 26 '19 at 12:02
  • 1
    The regex engine in Firefox does not support lookbehind. This **has** been implemented in chrome. Sometimes you can use capturing groups to get what you need. And your linked compatibility page shows it does NOT work in FF – Ron Rosenfeld Dec 26 '19 at 12:10

1 Answers1

0

Lookbehinds ((?<=RSI14) in your example) are not supported by Firefox and other browsers like IE.

The compatibility of lookbehinds is shown here https://caniuse.com/#feat=js-regexp-lookbehind.

You could use capturing groups like this example below. The $1 to 3 represent the groups and they've outputted here with underscores between, but you can do whatever you want.

text = "RSI14###Over"
pattern = /(RSI14)(.*?)(Over)/
$('body').html(text.replace(pattern, "$1_$2_$3"))
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
</body>
Rob Kwasowski
  • 2,690
  • 3
  • 13
  • 32