r/programminghorror • • Aug 28 '26

Javascript Seriously? Recursive Regex?

Post image
568 Upvotes

46 comments sorted by

View all comments

Show parent comment

10

u/digitalseraphim Aug 29 '26

I don't see anything "malformed", but pretty sure (?:\w|[^\w\s]) is just .

Edit: I see the mismatched parens now. On my phone, the \ before one of the opens was on the previous line and I missed it 3 times 😂

4

u/iakobski Aug 30 '26

I don't see anything "malformed", but pretty sure (?:\w|[^\w\s]) is just .

Yes, almost. It's any single word character, or any single character that's neither a word character nor a space. So it's simply "not a space character", or [^\s].

3

u/jordanbtucker Sep 01 '26

Which is just \S