Skip to content Skip to sidebar Skip to footer

Invalid Regular Expression: Invalid Group In Node.js

I am trying to map ELB load-balancer logs to have a common format like nginx and have this regex const splitElbEntry = (elbLogEntry) => R.match(/(?P[0-9-]+T[0-9:]+)

Solution 1:

The selected flavor in regexr is PCRE and your end flavor is JS. JS doesn't support (?P<name>...) notation. However, (?<name>...) would be implemented in ECMAScript 2018 (currently supported by Google Chrome).

You can't, as of now, use a named capturing group that works among all major browsers. Deal with simple numbered capturing groups.

Solution 2:

I got the required result using numbered capturing groups, thanks for the help.

https://regex101.com/r/JOlrxS/6

([0-9-]+T[0-9:]+)\.\S+\s+\S+\s+(\S+):\d+\s+\S+:\d+\s+\S+\s+(\S+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+\"\S+\s+\w+:\/\/([\w\-\.]*):\d+(\/\S*)\s+[^\"]+\"\s+\"([^\"]+)\"\s+\S+\s+\S+

Post a Comment for "Invalid Regular Expression: Invalid Group In Node.js"