Regular expresion not valid (node) but valid on online testers

Hello I am redoing some or the challenges, trying to use interesting tools such as regex.

I am trying to capitalize words, to match the first character in a word I use:
const firstLetter = /\b[a-zA-Z]/g

which seems to work fine. So I use that expresion as a base to create the one that captures the rest…
that would be:
const restLetter = /(?<=\b[a-z])[a-z]+\b/g

this regex seems valid and working on the website i was using to build it… as you can see on the link

but node will throw an invalid regular expression, invalid group error.

Do you know what could be happening?
It might be something silly but I have spent way too much time on this single challenge and Im losing hope and courdory, you probably know what I mean!

Not sure, but until 2018 javascript did not support lookbehinds (like the “(?<=\b[a-z])” in your expression) and it seems some browsers still don’t. This post may shed some light on your issue. Anyhow, there are ways of emulating lookbehind behavior without using one, as that post shows.

1 Like