Simon Willison’s Weblog

Subscribe

Friday, 20th January 2006

Tag Soup: Crazy parsing adventures. More bizzare browser behaviour.

# 9:57 am

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]

2006 » January

MTWTFSS
      1
2345678
9101112131415
16171819202122
23242526272829
3031