skip to Main Content

In JavaScript, is there a way to iterate over the lexical tokens of a string?

Given this string, which I receive from an endpoint: "u0000u0000u0000u001A%<some-random-textfcdtoolHxxx1-34e3-4069-b97c-xxxxxxxxxxxu001En" I would like to iterate the string to escape every sequence that starts with u. The resulting string would be: "\u0000\u0000\u0000\u001A%<some-random-textfcdtoolHxxx1-34e3-4069-b97c-xxxxxxxxxxx\u001En" Notice how f and n aren't escaped. So, how…

VIEW QUESTION
Back To Top
Search