Simon Willison’s Weblog

Subscribe

Entries tagged escaping in 2006

Filters: Type: entry × Year: 2006 × escaping × Sorted by date


Escaping regular expression characters in JavaScript

JavaScript’s support for regular expressions is generally pretty good, but there is one notable omission: an escaping mechanism for literal strings. Say for example you need to create a regular expression that removes a specific string from the end of a string. If you know the string you want to remove when you write the script this is easy:

[... 362 words]

Types

Years

Months

Tags