id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
Mmdn_RegExp/toString_74_0.txt
# RegExp.prototype.toString()
Mmdn_RegExp/Mmdn_RegExp_0_6.txt
-capturing_group) 15. [ Quantifier: *, +, ?, {n}, {n,}, {n,m} ](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier) 16. [ Unicode character class escape: \p{...}, \P{...} ](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) 17. [ Wildcard: . ](/en-US/do...
Mmdn_RegExp/toString_102_0.txt
Was this page helpful to you?
Mmdn_RegExp/Mmdn_RegExp_22_4.txt
uidelines/Attrib_copyright_license) . *[ Deprecated ]: Deprecated. Not for use in new websites. *[ Non-standard ]: Non-standard. Check cross-browser support before using.
Mmdn_RegExp/exec_114_0.txt
You can usually replace this kind of code with [ ` String.prototype.matchAll() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) to make it less error-prone.
Mmdn_RegExp/Mmdn_RegExp_5_1.txt
cated 8. [ ` RegExp: lastIndex ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) 9. [ ` RegExp.lastMatch ($&) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch) Deprecated 10. [ ` RegExp.lastParen ($+) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/R...
Mmdn_RegExp/Regularexpressions_12_0.txt
General-purpose scripting language
Mmdn_RegExp/exec_107_0.txt
If your regular expression uses the [ ` g ` ](/en- US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags) flag, you can use the ` exec() ` method multiple times to find successive matches in the same string. When you do so, the search starts at the substring of ` str ` specified by the regular ...
Mmdn_RegExp/Mmdn_RegExp_11_0.txt
* Skip to main content * Skip to search * Skip to select language [ MDN Web Docs ](/en-US/) Open main menu * References [ References ](/en-US/docs/Web) * [ Overview / Web Technology Web technology reference for developers ](/en-US/docs/Web) * [ HTML Structure of content on the web ](/en-US/do...
Mmdn_RegExp/exec_15_0.txt
Protocol for transmitting web resources
Mmdn_RegExp/Mmdn_RegExp_2_2.txt
ect/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 2. [ ` Object.prototype....
Mmdn_RegExp/Regularexpressions_222_0.txt
Deprecated
Mmdn_RegExp/javascriptregexpexer_8_0.txt
**JavaScript Code:**
Mmdn_RegExp/Regularexpressions_111_0.txt
` ^ ` , ` $ ` , ` \b ` , ` \B ` , ` x(?=y) ` , ` x(?!y) ` , ` (?<=y)x ` , ` (?<!y)x ` |
Mmdn_RegExp/toString_85_0.txt
In practice, it reads the regex's [ ` source ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) and [ ` flags ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags) properties and returns a string in the form ` /source/flags ` . The ` toString() ` return value is guaranteed to be a p...
Mmdn_RegExp/exec_115_0.txt
### Using exec() with RegExp literals
Mmdn_RegExp/Mmdn_RegExp_27_4.txt
new websites. *[ Non-standard ]: Non-standard. Check cross-browser support before using.
Mmdn_RegExp/Regularexpressions_123_0.txt
If escape strings are not already part of your pattern you can add them using [ ` String.prototype.replace() ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) :
Mmdn_RegExp/exec_30_0.txt
Learn web development
Mmdn_RegExp/Mmdn_RegExp_24_3.txt
chAll) (which calls [ ` RegExp.prototype[@@matchAll]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll) ): ` y ` , ` g ` and ` gy ` are all different. * For ` y ` regexes: ` matchAll() ` throws; ` [@@matchAll]() ` yields the ` exec() ` result exactly once, without updating the regex's ` l...
Mmdn_RegExp/toString_16_0.txt
](/en-US/docs/Web/HTTP)
Mmdn_RegExp/Mmdn_RegExp_11_3.txt
s content ](https://github.com/mdn/content/issues/new?template=page-report.yml&mdn- url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen- US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FRegExp%2Fflags&metadata=%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EPage+report+details%3C%2...
Mmdn_RegExp/Regularexpressions_23_0.txt
* [ Web Technology
Mmdn_RegExp/Regularexpressions_13_0.txt
](/en-US/docs/Web/JavaScript)
Mmdn_RegExp/Mmdn_RegExp_5_0.txt
* Skip to main content * Skip to search * Skip to select language [ MDN Web Docs ](/en-US/) Open main menu * References [ References ](/en-US/docs/Web) * [ Overview / Web Technology Web technology reference for developers ](/en-US/docs/Web) * [ HTML Structure of content on the web ](/en-US/do...
Mmdn_RegExp/Regularexpressions_120_0.txt
Similarly, if you're writing a regular expression literal and need to match a slash ("/"), you need to escape that (otherwise, it terminates the pattern). For instance, to search for the string "/example/" followed by one or more alphabetic characters, you'd use ` /\/example\/[a-z]+/i ` —the backslashes before each s...
Mmdn_RegExp/Mmdn_RegExp_3_3.txt
md?plain=1 "Folder: en-us/web/javascript/reference/global_objects/regexp/source \(Opens in a new tab\)") • [ Report a problem with this content ](https://github.com/mdn/content/issues/new?template=page-report.yml&mdn- url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen- US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Obj...
Mmdn_RegExp/Mmdn_RegExp_4_0.txt
* Skip to main content * Skip to search * Skip to select language [ MDN Web Docs ](/en-US/) Open main menu * References [ References ](/en-US/docs/Web) * [ Overview / Web Technology Web technology reference for developers ](/en-US/docs/Web) * [ HTML Structure of content on the web ](/en-US/do...
Mmdn_RegExp/Mmdn_RegExp_2_0.txt
* Skip to main content * Skip to search * Skip to select language [ MDN Web Docs ](/en-US/) Open main menu * References [ References ](/en-US/docs/Web) * [ Overview / Web Technology Web technology reference for developers ](/en-US/docs/Web) * [ HTML Structure of content on the web ](/en-US/do...
Mmdn_RegExp/exec_0_0.txt
* Skip to main content * Skip to search * Skip to select language
Mmdn_RegExp/Mmdn_RegExp_25_1.txt
/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) 9. _[ ` RegExp.lastMatch ($&) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch) Deprecated _ 10. [ ` RegExp.lastParen ($+) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen) Deprecated 11. ...
Mmdn_RegExp/toString_82_0.txt
A string representing the given object.
Mmdn_RegExp/Mmdn_RegExp_26_0.txt
* Skip to main content * Skip to search * Skip to select language [ MDN Web Docs ](/en-US/) Open main menu * References [ References ](/en-US/docs/Web) * [ Overview / Web Technology Web technology reference for developers ](/en-US/docs/Web) * [ HTML Structure of content on the web ](/en-US/do...
Mmdn_RegExp/Mmdn_RegExp_25_2.txt
Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 2. [ ` Object.prototy...
Mmdn_RegExp/exec_124_0.txt
* [ Regular expressions ](/en-US/docs/Web/JavaScript/Guide/Regular_expressions) guide * [ ` RegExp ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
Mmdn_RegExp/Mmdn_RegExp_23_2.txt
rence/Global_Objects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated ...
Mmdn_RegExp/exec_3_0.txt
Web technology reference for developers
Mmdn_RegExp/exec_89_0.txt
` groups `
Mmdn_RegExp/Mmdn_RegExp_27_3.txt
ce/Global_Objects/RegExp/input) * [ ` RegExp.lastMatch ($&) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch) * [ ` RegExp.leftContext ($`) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext) * [ ` RegExp.rightContext ($') ` ](/en-US/docs/Web/JavaScript/Reference/Gl...
Mmdn_RegExp/Mmdn_RegExp_8_4.txt
](/) Your blueprint for a better internet. * [ MDN on Mastodon ](https://mozilla.social/@mdn) * [ MDN on X (formerly Twitter) ](https://twitter.com/mozdevnet) * [ MDN on GitHub ](https://github.com/mdn/) * [ MDN Blog RSS Feed ](/en-US/blog/rss.xml) ## MDN * [ About ](/en-US/about) * [ Blog ](/en-US...
Mmdn_RegExp/toString_84_0.txt
The [ ` RegExp ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) object overrides the ` toString() ` method of the [ ` Object ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/Object) object; it does not inherit [ ` Object.prototype.toString() ` ](/en- US/docs/Web/JavaScript/Reference/Global_Object...
Mmdn_RegExp/Regularexpressions_215_0.txt
## Our communities
Mmdn_RegExp/Regularexpressions_76_1.txt
er ](/en-US/docs/Web/JavaScript/Reference/Errors/Reserved_identifier) 22. [ SyntaxError: a declaration in the head of a for-of loop can't have an initializer ](/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-of_initializer) 23. [ SyntaxError: applying the 'delete' operator to an unqualified name is deprecated ]...
Mmdn_RegExp/toString_51_0.txt
All browser compatibility updates at a glance
Mmdn_RegExp/Mmdn_RegExp_22_2.txt
ects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 2. [ ` Object.pr...
Mmdn_RegExp/toString_18_0.txt
Interfaces for building web applications
Mmdn_RegExp/toString_38_0.txt
* [ JavaScript
Mmdn_RegExp/exec_13_0.txt
](/en-US/docs/Web/JavaScript)
Mmdn_RegExp/Regularexpressions_161_0.txt
with:
Mmdn_RegExp/Regularexpressions_207_0.txt
[ View this page on GitHub ](https://github.com/mdn/content/blob/main/files/en- us/web/javascript/guide/regular_expressions/index.md?plain=1 "Folder: en- us/web/javascript/guide/regular_expressions \(Opens in a new tab\)") • [ Report a problem with this content ](https://github.com/mdn/content/issues/new?template=pa...
Mmdn_RegExp/Regularexpressions_32_0.txt
* [ HTML
Mmdn_RegExp/Regularexpressions_11_0.txt
* [ JavaScript
Mmdn_RegExp/exec_143_0.txt
* [ Website Privacy Notice ](https://www.mozilla.org/privacy/websites/) * [ Cookies ](https://www.mozilla.org/privacy/websites/#cookies) * [ Legal ](https://www.mozilla.org/about/legal/terms/mozilla) * [ Community Participation Guidelines ](https://www.mozilla.org/about/governance/policies/participation/)
Mmdn_RegExp/Mmdn_RegExp_3_2.txt
ects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 2. [ ` Object.pr...
Mmdn_RegExp/toString_30_0.txt
Learn web development
Mmdn_RegExp/Mmdn_RegExp_15_4.txt
es ](/en-US/docs/Web) * [ Learn Web Development ](/en-US/docs/Learn) * [ MDN Plus ](/en-US/plus) * [ Hacks Blog ](https://hacks.mozilla.org/) [ Mozilla logo ](https://www.mozilla.org/) * [ Website Privacy Notice ](https://www.mozilla.org/privacy/websites/) * [ Cookies ](https://www.mozilla.org/privacy/webs...
Mmdn_RegExp/javascriptregexpexer_18_0.txt
**What is the difficulty level of this exercise?**
Mmdn_RegExp/Regularexpressions_61_0.txt
Theme
Mmdn_RegExp/toString_77_0.txt
## Syntax
Mmdn_RegExp/toString_25_0.txt
](/en-US/docs/Web)
Mmdn_RegExp/exec_147_0.txt
Non-standard
Mmdn_RegExp/Regularexpressions_131_0.txt
Method | Description ---|--- [ ` exec() ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) | Executes a search for a match in a string. It returns an array of information or ` null ` on a mismatch. [ ` test() ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) | Tests for a matc...
Mmdn_RegExp/Mmdn_RegExp_1_3.txt
ed. When the regex is sticky and global, it will still perform sticky matches — i.e. it will not match any occurrences beyond the ` lastIndex ` . js console.log(Array.from("ab-c".matchAll(/[abc]/gy))); // [ [ "a" ], [ "b" ] ] If the current match is an empty string, the [ ` lastIndex ` ](/e...
Mmdn_RegExp/toString_79_0.txt
### Parameters
Mmdn_RegExp/toString_35_0.txt
* [ CSS
Mmdn_RegExp/Mmdn_RegExp_9_4.txt
plus) * [ Report an issue ](/en-US/docs/MDN/Community/Issues) ## Our communities * [ MDN Community ](/en-US/community) * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236) * [ MDN Chat ](/discord) ## Developers * [ Web Technologies ](/en-US/docs/Web) * [ Learn Web Development ](/en-US/docs/Learn) ...
Mmdn_RegExp/Mmdn_RegExp_20_3.txt
## Browser compatibility BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data. ## See also * [ ` RegExp.input ($_) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input) * [ ` RegExp.lastMatch ($&) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Obje...
Mmdn_RegExp/toString_115_0.txt
* [ MDN Community ](/en-US/community) * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236) * [ MDN Chat ](/discord)
Mmdn_RegExp/Mmdn_RegExp_14_2.txt
JavaScript/Reference/Global_Objects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) D...
Mmdn_RegExp/toString_73_0.txt
* Try it * Syntax * Description * Examples * Specifications * Browser compatibility * See also
Mmdn_RegExp/Regularexpressions_25_0.txt
](/en-US/docs/Web)
Mmdn_RegExp/Regularexpressions_146_0.txt
const myArray = /d(b+)d/g.exec("cdbbdbsbz"); console.log(`The value of lastIndex is ${/d(b+)d/g.lastIndex}`);
Mmdn_RegExp/exec_140_0.txt
## Developers
Mmdn_RegExp/Regularexpressions_84_0.txt
## Creating a regular expression
Mmdn_RegExp/exec_16_0.txt
](/en-US/docs/Web/HTTP)
Mmdn_RegExp/Regularexpressions_167_0.txt
const str = "fee fi fo fum"; const re = /\w+\s/g;
Mmdn_RegExp/Regularexpressions_149_0.txt
### Advanced searching with flags
Mmdn_RegExp/Regularexpressions_108_0.txt
If you want to look at all the special characters that can be used in regular expressions in a single table, see the following:
Mmdn_RegExp/exec_52_0.txt
](/en-US/plus/updates)
Mmdn_RegExp/exec_17_0.txt
* [ Web APIs
Mmdn_RegExp/exec_14_0.txt
* [ HTTP
Mmdn_RegExp/Regularexpressions_157_0.txt
const re = /\w+\s/g; const str = "fee fi fo fum"; const myArray = str.match(re); console.log(myArray);
Mmdn_RegExp/exec_85_0.txt
` index `
Mmdn_RegExp/javascriptregexpexer_22_0.txt
* * *
Mmdn_RegExp/toString_37_0.txt
](/en-US/docs/Learn/CSS)
Mmdn_RegExp/Regularexpressions_18_0.txt
Interfaces for building web applications
Mmdn_RegExp/javascriptregexpexer_29_0.txt
©w3resource.com 2011-2024
Mmdn_RegExp/exec_22_0.txt
](/en-US/docs/Mozilla/Add-ons/WebExtensions)
Mmdn_RegExp/toString_120_0.txt
Visit [ Mozilla Corporation’s ](https://www.mozilla.org) not-for-profit parent, the [ Mozilla Foundation ](https://foundation.mozilla.org/) . Portions of this content are ©1998– 2024 by individual mozilla.org contributors. Content available under [ a Creative Commons license ](/en- US/docs/MDN/Writing_guideli...
Mmdn_RegExp/Regularexpressions_130_0.txt
Regular expressions are used with the [ ` RegExp ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) methods [ ` test() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) and [ ` exec() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) and with the [ ` String ` ](/en- U...
Mmdn_RegExp/toString_24_0.txt
Web technology reference for developers
Mmdn_RegExp/exec_127_0.txt
Yes No
Mmdn_RegExp/exec_100_0.txt
### Using exec()
Mmdn_RegExp/Regularexpressions_88_0.txt
Regular expression literals provide compilation of the regular expression when the script is loaded. If the regular expression remains constant, using this can improve performance.
Mmdn_RegExp/Mmdn_RegExp_12_2.txt
nce/Global_Objects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 2....
Mmdn_RegExp/Mmdn_RegExp_6_2.txt
rence/Global_Objects/Object/constructor) 2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 13. Methods 1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated ...
Mmdn_RegExp/Regularexpressions_58_0.txt
](/en-US/plus/docs/faq)
Mmdn_RegExp/Mmdn_RegExp_9_1.txt
8. [ ` RegExp: lastIndex ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) 9. [ ` RegExp.lastMatch ($&) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch) Deprecated 10. [ ` RegExp.lastParen ($+) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/las...
Mmdn_RegExp/Regularexpressions_127_0.txt
### Using parentheses
Mmdn_RegExp/javascriptregexpexer_9_0.txt
function upper_case(str) { regexp = /^[A-Z]/; if (regexp.test(str)) { console.log("String's first character is uppercase"); } else { console.log("String's first character is not uppercase"); } } upper_case('Abcd'); upper_case('abcd');