-1

I have a couple regular expressions that work just fine in chrome but do not in edge or internet explorer. It is giving an error of unexpected quantifier when debugging on the browser. The input was 89 9 5 for this error. Any ideas for this?

var fps1 = new RegExp(
  "(?<Unit>[a-p])\\W*(?<Section>\\d+)\\W+(?<LatDegrees>\\d+)-(?<LatMinutes>\\d+)\\W+(?<LongDegrees>\\d+)-(?<LongMinutes>\\d+)");

var dls1 = new RegExp(
  "[/-](L[a-z]*)?\\W*(?<Lsd>\\d+)\\W*(S[a-z]*|\\W)\\W*(?<Section>\\d+)\\W*(T[a-z]*|\\W)\\W*(?<Township>\\d+)\\W*(R[a-z]*|\\W)\\W*(?<Range>\\d+)\\W*([WM][a-z]*|\\W)\\W*(?<Meridian>\\d)\\b");

var dls2 = new RegExp(
  "(L[a-z]*)?\\W*(?<Lsd>\\d+)\\W*(S[a-z]*|\\W)\\W*(?<Section>\\d+)\\W*(T[a-z]*|\\W)\\W*(?<Township>\\d+)\\W*(R[a-z]*|\\W)\\W*(?<Range>\\d+)\\W*([WM][a-z]*|\\W)\\W*(?<Meridian>\\d)\\b");

var dls3 = new RegExp(
  "(S[a-z]*)?\\W*(?<Section>\\d+)\\W*(T[a-z]*|\\W)\\W*(?<Township>\\d+)\\W*(R[a-z]*|\\W)\\W*(?<Range>\\d+)\\W*([WM][a-z]*|\\W)\\W*(?<Meridian>\\d)\\b");

var dls4 = new RegExp(
  "(T[a-z]*)?\\W*(?<Township>\\d+)\\W*(R[a-z]*|\\W)\\W*(?<Range>\\d+)\\W*([WM][a-z]*|\\W)\\W*(?<Meridian>\\d)\\b");

var nts1 = new RegExp(
  "(?<Quarter>[abcd])\\W+(?<Unit>\\d+)\\W+(?<Block>[abcdefghijkl])/(?<Sheet>\\d+)\\W+(?<Subdivision>[abcdefghijklmnop])\\W+(?<Sixteenth>\\d+)");

var nts2 = new RegExp(
  "(?<Unit>\\d+)\\W+(?<Block>[abcdefghijkl])/(?<Sheet>\\d+)\\W+(?<Subdivision>[abcdefghijklmnop])\\W+(?<Sixteenth>\\d+)");
var nts3 = new RegExp(
  "((?<Block>\\w)/)?(?<Sheet>\\d+)\\W+(?<Subdivision>[abcdefghijklmnop])\\W+(?<Sixteenth>\\d+)");

When stepping through with the Edge debugging tools it does not go past the first regular expression, the javascript execution just stops and the error in the developer window was just unexpected quantifier and no other hints.

barbsan
  • 3,418
  • 11
  • 21
  • 28
scott lafoy
  • 1,001
  • 1
  • 13
  • 30
  • 1. why do you not use the litteral RegExp notation ? 2. are you trying to [parse XML with a RegExp](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) ? and 3. would you mind narrowing down the error ? though I think I spotted a few already… – Touffy Feb 26 '19 at 14:54
  • I am trying to parse geological grid coordinates. These were written by a peer long gone in c# many many years ago and are proven accurate. I didn't want to mess that up. – scott lafoy Feb 26 '19 at 15:00

1 Answers1

2

The issue here is JavaScript does not support named groups with the exception of when running in chrome. To fix this I just had to remove all of the named group syntax.

Remove ?<NAMED_GROUP>

barbsan
  • 3,418
  • 11
  • 21
  • 28
scott lafoy
  • 1,001
  • 1
  • 13
  • 30