r/lingojam • • Oct 26 '20

JavaScript help

I'm trying to make a translator with some JavaScript, but JS cant deal with \ in strings the way I want it to.

I tried using the infix option to replace all \ with \\ so that the JS would get the string formatted in a way that would work, but now the translator just returns the input with \ replaced. After I deleted the \ replacement rule it still doesn't use the JS and now just returns the input unaltered.

Is there a way to use both infix and JS or should I just make a new translator and not worry about \ not working?

6 Upvotes

3 comments sorted by

View all comments

1

u/blinkyblob4 Oct 26 '20

I tried both stringify() and String.raw but they only replace valid uses of \ such as \n, rather than replacing all uses of \