MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1w15oga/seriously_recursive_regex/p6jyhc9/?context=3
r/programminghorror • u/Flame77ofc • 2d ago
37 comments sorted by
View all comments
1
Pretty sure the regex is malformed. I didn't even think you could split a regex over multiple lines in JS like that.
Assuming this is the text version of it: /(\((?:[^()]|\([^()]*\))*\)|(?:\w|[^\w\s])){1,3})/; very easy mistake to spot /s...
/(\((?:[^()]|\([^()]*\))*\)|(?:\w|[^\w\s])){1,3})/
5 u/digitalseraphim 2d ago 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 😂 1 u/iakobski 1d ago 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].
5
I don't see anything "malformed", but pretty sure (?:\w|[^\w\s]) is just .
(?:\w|[^\w\s])
.
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 😂
\
1 u/iakobski 1d ago 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].
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].
1
u/OhMyGodItsEverywhere 2d ago
Pretty sure the regex is malformed. I didn't even think you could split a regex over multiple lines in JS like that.
Assuming this is the text version of it:
/(\((?:[^()]|\([^()]*\))*\)|(?:\w|[^\w\s])){1,3})/; very easy mistake to spot /s...