prototype/src/lang/regexp.js

24 lines
621 B
JavaScript
Raw Normal View History

2009-03-05 19:56:01 +00:00
/** section: Language
* class RegExp
2008-12-14 04:36:59 +00:00
**/
/** alias of: RegExp#test
* RegExp#match(str) -> Boolean
*
* Return true if string matches the regular expression, false otherwise.
**/
2008-12-11 10:42:15 +00:00
RegExp.prototype.match = RegExp.prototype.test;
2008-12-14 04:36:59 +00:00
/**
* RegExp.escape(str) -> String
* - str (String): A string intended to be used in a `RegExp` constructor.
*
* Escapes any characters in the string that have special meaning in a
* regular expression.
*
* Use before passing a string into the `RegExp` constructor.
**/
2008-12-11 10:42:15 +00:00
RegExp.escape = function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};