English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
JavaScript RegExp RegExp Object
exec()This method is used to search for matches in the specified string.
If a match is found, this method returns the matched text; otherwise, it returns null.
regex.exec(string)
var str = "www.oldtoolbag.com"; var regex = new RegExp("h"); var ans = regex.exec(str);Test See‹/›
All browsers fully support the exec() method:
Method | |||||
exec() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
string | String that matches the regular expression |
Return Value: | If a match is found, an array containing the matched text is returned; otherwise, null is returned. |
---|---|
JavaScript Version: | ECMAScript 1 |