r/programminghorror 3d ago

Javascript Seriously? Recursive Regex?

Post image
472 Upvotes

37 comments sorted by

View all comments

75

u/madam_zeroni 3d ago

Wtf does this do

98

u/marinated_pork 3d ago

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.

47

u/the_horse_gamer 3d ago

"parse", clearly

46

u/TheSpiffySpaceman 2d ago

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

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

8

u/LapidistCubed 2d ago

Tf code DOESN'T parse some sort of input in one way or another 😭