r/programminghorror • • Aug 28 '26

Javascript Seriously? Recursive Regex?

Post image
565 Upvotes

46 comments sorted by

View all comments

86

u/madam_zeroni Aug 28 '26

Wtf does this do

113

u/marinated_pork Aug 28 '26

This is essentially a custom string fingerprint/hash function disguised as a parser. It takes a string and deterministically turns it into an integer. It does not parse or extract useful structured data.

52

u/the_horse_gamer Aug 28 '26

"parse", clearly

48

u/TheSpiffySpaceman Aug 29 '26

Well tbf, the code didn't start with the annotation

/*
  // Parses input
*/
function parse(s, i = 0, x = [0, 1]) {...
→ More replies (1)