F
F
FinchRED2020-12-21 18:54:09
JavaScript
FinchRED, 2020-12-21 18:54:09

Problem parsing (regex) URL tags in Safari / "invalid group specifier name"?

In other browsers everything is correct.
But in safari it gives out in the second line.
"invalid group specifier name "

let url_utm= location.search;
let get_metk =Object.fromEntries((url_utm.match(/(?<=utm_).+?=[^&]*/gu) || []).map(n => n.split('=')));
  console.log(get_metk['source']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-12-21
@FinchRED

Safari doesn't support lookbehind .
Regular expressions are not needed:

const utm = Object.fromEntries(Array
  .from(new URLSearchParams(location.search))
  .filter(n => n[0].startsWith('utm_'))
  .map(n => [ n[0].slice(4), n[1] ])
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question