Positive lookbehind assertion not supported in JS?

I have been stuck trying to figure out regular expressions in solving a problem. I finally figured out that a positive lookbehind should work (could see in an online regex tester that it works for php) but not JS , soooo frustrating!

Is there a workaround , or do I try a different solution?

This is what I had btw for “title case a sentence”:

let regEx = /(?<= )[a-z]/g;

There’s a space to the right of the = btw , but it doesn’t render correctly here.
so it should highlight the first letter of each word. But not in js, it seems , even though MDN has a tutuorial all about assertions in JS with this assertion.

Thanks for the rant.

Okay is there a link to the challenge you got stuck onto?
Also if you want to know the other way it is possible but, it’s much more advanced. and i would’t recomend to use it. FCC is set to help beginners there is logic behind the reasoning and this lesson which you might not have yet comprhended yet.

Chrome as support for Lookbehind and it seems like the challenge isn’t throwing an error when using it (not sure if it will work as I didn’t test it).

It would help if you showed how you are planning to use the regex exactly. Did you try and log out using it with a match?

let regEx = /(?<= )[a-z]/g;

"I'm a little tea pot".match(regEx)
// ["a", "l", "t", "p"]

"sHoRt AnD sToUt".match(regEx)
// ["s"]

// null

You don’t need to use Lookbehind (or a regex for that matter).

This is the challenge BTW.

Thanks for the replies, I don’t understand how all the tutorials explain lookbehinds for JS, yet there doesn’t seem to be support for it , JS doesn’t support it .
So I’ll have to figure out another solution. I tried in Chrome it didn’t work, but thanks for the replies :slight_smile: