Skip to content

Posts tagged javascript

Posts under this tag. Back to all posts when you want the full stream.

@latest_post

TIL: Escape JavaScript RegExp string

Sometimes you try to use certain strings to create regular expressions.

The problem is these string might contain characters that have special meaning inside a RegExp. For example:

TypeScript
const myString = '[Hello?](World)!!!'

To escape it for safe use as a regex pattern, lodash provides escapeRegExp.

TypeScript
const myString = '[Hello?](World)!!!'
// "\\[Hello\\?\\]\\(World\\)!!!"

Writing stream

3 older posts tagged javascript.