id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
Mmdn_RegExp/toString_10_0.txt
](/en-US/docs/Web/CSS)
Mmdn_RegExp/Regularexpressions_122_0.txt
If using the ` RegExp ` constructor with a string literal, remember that the backslash is an escape in string literals, so to use it in the regular expression, you need to escape it at the string literal level. ` /a\*b/ ` and ` new RegExp("a\\*b") ` create the same expression, which searches for "a" followed by a liter...
Mmdn_RegExp/Regularexpressions_54_0.txt
Learn how to use MDN Plus
Mmdn_RegExp/Regularexpressions_19_0.txt
](/en-US/docs/Web/API)
Mmdn_RegExp/toString_100_0.txt
* [ ` Object.prototype.toString() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
Mmdn_RegExp/Regularexpressions_174_0.txt
Unicode regular expressions have different execution behavior as well. [ ` RegExp.prototype.unicode ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) contains more explanation about this.
Mmdn_RegExp/Mmdn_RegExp_16_4.txt
nt ](/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/websites/#cookies) * [ Legal ](https://www.mozill...
Mmdn_RegExp/Regularexpressions_204_0.txt
Yes No
Mmdn_RegExp/toString_6_0.txt
Structure of content on the web
Mmdn_RegExp/Regularexpressions_150_0.txt
Regular expressions have optional flags that allow for functionality like global searching and case-insensitive searching. These flags can be used separately or together in any order, and are included as part of the regular expression.
Mmdn_RegExp/Regularexpressions_118_0.txt
### Escaping
Mmdn_RegExp/Mmdn_RegExp_1_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_16_2.txt
obal_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. [ ` O...
Mmdn_RegExp/exec_117_0.txt
const matches = /(hello \S+)/.exec("This is a hello world!"); console.log(matches[1]);
Mmdn_RegExp/exec_5_0.txt
* [ HTML
Mmdn_RegExp/Mmdn_RegExp_24_4.txt
index 2 is not the beginning of the string or line regex2.lastIndex = 2; regex2.test(".\nfoo"); // true - index 2 is the beginning of a line ## Specifications Specification --- [ ECMAScript Language Specification # sec-get-regexp.prototype.sticky ](https://tc39.es/ecma262/multipage/text- proces...
Mmdn_RegExp/Regularexpressions_140_0.txt
With these scripts, the match succeeds and returns the array and updates the properties shown in the following table.
Mmdn_RegExp/Regularexpressions_105_0.txt
Groups group multiple patterns as a whole, and capturing groups provide extra submatch information when using a regular expression pattern to match against a string. Backreferences refer to a previously captured group in the same regular expression.
Mmdn_RegExp/exec_39_0.txt
Learn to run scripts in the browser
Mmdn_RegExp/toString_23_0.txt
* [ Web Technology
Mmdn_RegExp/Mmdn_RegExp_9_3.txt
gExp ` , the ` MyRegExp ` species is the ` MyRegExp ` constructor. However, you might want to overwrite this, in order to return parent ` RegExp ` objects in your derived class methods: js class MyRegExp extends RegExp { // Overwrite MyRegExp species to the parent RegExp constructor static g...
Mmdn_RegExp/exec_41_0.txt
* [ Accessibility
Mmdn_RegExp/Regularexpressions_208_0.txt
[ MDN logo ](/)
Mmdn_RegExp/Mmdn_RegExp_29_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_103_0.txt
The following table shows the state of ` result ` after running this script:
Mmdn_RegExp/javascriptregexpexer_25_0.txt
* * *
Mmdn_RegExp/Regularexpressions_197_0.txt
[ Regex interactive tutorial ](https://regexlearn.com/)
Mmdn_RegExp/Mmdn_RegExp_4_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_11_0.txt
* [ JavaScript
Mmdn_RegExp/Mmdn_RegExp_0_1.txt
ipt/Guide/Keyed_collections) 12. [ Working with objects ](/en-US/docs/Web/JavaScript/Guide/Working_with_objects) 13. [ Using classes ](/en-US/docs/Web/JavaScript/Guide/Using_classes) 14. [ Using promises ](/en-US/docs/Web/JavaScript/Guide/Using_promises) 15. [ JavaScript typed arrays ](/en-US/docs/Web/J...
Mmdn_RegExp/Regularexpressions_107_0.txt
Indicate numbers of characters or expressions to match.
Mmdn_RegExp/exec_49_0.txt
](/en-US/plus/ai-help)
Mmdn_RegExp/Mmdn_RegExp_0_8.txt
properties ](/en-US/docs/Web/JavaScript/Reference/Errors/No_properties) 59. [ TypeError: "x" is (not) "y" ](/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_type) 60. [ TypeError: "x" is not a constructor ](/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor) 61. [ TypeError: "x" is not a f...
Mmdn_RegExp/toString_53_0.txt
* [ Documentation
Mmdn_RegExp/javascriptregexpexer_30_0.txt
* [ Privacy ](https://www.w3resource.com/privacy.php) * [ About ](https://www.w3resource.com/about.php) * [ Contact ](https://www.w3resource.com/contact.php) * [ Feedback ](https://www.w3resource.com/feedback.php) * [ Advertise ](https://www.w3resource.com/advertise.php)
Mmdn_RegExp/Mmdn_RegExp_16_3.txt
r}]/v; console.log(regex.unicodeSets); // true ## Specifications Specification --- [ ECMAScript Language Specification # sec-get-regexp.prototype.unicodesets ](https://tc39.es/ecma262/multipage/text-processing.html#sec-get- regexp.prototype.unicodesets) ## Browser compatibility BCD tables...
Mmdn_RegExp/Mmdn_RegExp_0_10.txt
Web/JavaScript/Reference/Global_Objects/URIError) * [ ` InternalError ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError) Non-standard ### Numbers and dates These are the base objects representing numbers, dates, and mathematical calculations. * [ ` Number ` ](/en-US/docs/Web/JavaScript/Refe...
Mmdn_RegExp/Regularexpressions_60_0.txt
Search MDN Clear search input Search
Mmdn_RegExp/toString_36_0.txt
Learn to style content using CSS
Mmdn_RegExp/Regularexpressions_113_0.txt
` ( _x_ ) ` , ` (?<Name>x) ` , ` (?: _x_ ) ` , ` \ _n_ ` , ` \k<Name> ` |
Mmdn_RegExp/exec_50_0.txt
* [ Updates
Mmdn_RegExp/Regularexpressions_125_0.txt
The "g" after the regular expression is an option or flag that performs a global search, looking in the whole string and returning all matches. It is explained in detail below in Advanced Searching With Flags .
Mmdn_RegExp/Regularexpressions_87_0.txt
const re = /ab+c/;
Mmdn_RegExp/exec_4_0.txt
](/en-US/docs/Web)
Mmdn_RegExp/Regularexpressions_44_0.txt
* Plus [ Plus ](/en-US/plus) * [ Overview
Mmdn_RegExp/Mmdn_RegExp_20_2.txt
bal_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. [ ` Ob...
Mmdn_RegExp/Regularexpressions_173_0.txt
/\p{L}*/u;
Mmdn_RegExp/Mmdn_RegExp_22_3.txt
astIndex) * [ ` RegExp.prototype.dotAll ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll) * [ ` RegExp.prototype.hasIndices ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices) * [ ` RegExp.prototype.ignoreCase ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegE...
Mmdn_RegExp/javascriptregexpexer_17_0.txt
**Previous:** [ JavaScript Regular Expression exercises. ](https://www.w3resource.com/javascript-exercises/javascript-regexp- exercises.php) **Next:** [ Write a JavaScript program to check a credit card number ( format 9999-9999-9999-9999 ). ](https://www.w3resource.com/javascript- exercises/javascript-regexp-exercise-...
Mmdn_RegExp/Regularexpressions_14_0.txt
* [ HTTP
Mmdn_RegExp/Mmdn_RegExp_24_5.txt
* [ 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/websites/#cookies) * [ Legal ](https://www.mozilla.org/about/legal/terms/mozilla) * [ Community Partic...
Mmdn_RegExp/Mmdn_RegExp_28_4.txt
he search starts at the substring of ` str ` specified by the regular expression's [ ` lastIndex ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) property ( [ ` test() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) will also advance the [ ` lastIndex ` ](/en- US/docs/Web/...
Mmdn_RegExp/toString_119_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/Regularexpressions_134_0.txt
const myRe = /d(b+)d/g; const myArray = myRe.exec("cdbbdbsbz");
Mmdn_RegExp/Mmdn_RegExp_28_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_153_0.txt
const re = /pattern/flags;
Mmdn_RegExp/exec_111_0.txt
Found abb. Next match starts at 3 Found ab. Next match starts at 9
Mmdn_RegExp/toString_88_0.txt
The following example displays the string value of a [ ` RegExp ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) object:
Mmdn_RegExp/Regularexpressions_49_0.txt
](/en-US/plus/ai-help)
Mmdn_RegExp/Mmdn_RegExp_10_4.txt
eprecated ]: Deprecated. Not for use in new websites. *[ Deprecated ]: Deprecated. Not for use in new websites. *[ Non-standard ]: Non-standard. Che...
Mmdn_RegExp/javascriptregexpexer_6_0.txt
![JavaScript: Check whether the first character of a string is uppercase or not ](https://www.w3resource.com/w3r_images/javascript-regexp-image- exercise-1.png)
Mmdn_RegExp/exec_138_0.txt
## Our communities
Mmdn_RegExp/Regularexpressions_176_0.txt
**Note:** Several examples are also available in:
Mmdn_RegExp/exec_146_0.txt
]: Deprecated. Not for use in new websites. *[
Mmdn_RegExp/exec_142_0.txt
[ Mozilla logo ](https://www.mozilla.org/)
Mmdn_RegExp/Mmdn_RegExp_12_3.txt
ways requires setting ` lastIndex ` . It always matches strictly at ` lastIndex ` and does not attempt any later positions. This is usually useful for writing parsers, when you want to match tokens only at the current position. js const stringPattern = /"[^"]*"/y; const input = `const message = "Hel...
Mmdn_RegExp/Regularexpressions_77_1.txt
b/JavaScript/Reference/Errors/Deprecated_source_map_pragma) 59. [ TypeError: 'x' is not iterable ](/en-US/docs/Web/JavaScript/Reference/Errors/is_not_iterable) 60. [ TypeError: "x" has no properties ](/en-US/docs/Web/JavaScript/Reference/Errors/No_properties) 61. [ TypeError: "x" is (not) "y" ](/en-US/docs/Web/JavaScri...
Mmdn_RegExp/exec_93_0.txt
The ` indices ` array additionally has a ` groups ` property, which holds a [ ` null ` -prototype object ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects) of all named capturing groups. The keys are the names of the capturing groups, and each value is a two-element array, with the fi...
Mmdn_RegExp/exec_67_0.txt
Filter sidebar Clear filter input
Mmdn_RegExp/Regularexpressions_72_0.txt
41. [ Map ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) 42. [ Math ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) 43. [ NaN ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) 44. [ Number ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) 45. [ Object ](/en-US/docs/Web/JavaS...
Mmdn_RegExp/Regularexpressions_77_0.txt
27. [ SyntaxError: continue must be inside loop ](/en-US/docs/Web/JavaScript/Reference/Errors/Bad_continue) 28. [ SyntaxError: for-in loop head declarations may not have initializers ](/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer) 29. [ SyntaxError: function statement requires a name ](/en-US/...
Mmdn_RegExp/javascriptregexpexer_15_0.txt
See the Pen [ javascript-regexp-exercise-1 ](https://codepen.io/w3resource/pen/jeWKqq/) by w3resource ( [ @w3resource ](https://codepen.io/w3resource) ) on [ CodePen ](https://codepen.io) .
Mmdn_RegExp/exec_57_0.txt
Frequently asked questions about MDN Plus
Mmdn_RegExp/toString_41_0.txt
* [ Accessibility
Mmdn_RegExp/exec_91_0.txt
` indices ` Optional
Mmdn_RegExp/Regularexpressions_216_0.txt
* [ MDN Community ](/en-US/community) * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236) * [ MDN Chat ](/discord)
Mmdn_RegExp/javascriptregexpexer_16_0.txt
**Improve this sample solution and post your code through Disqus.**
Mmdn_RegExp/toString_70_0.txt
1. [ Standard built-in objects ](/en-US/docs/Web/JavaScript/Reference/Global_Objects) 2. [ ` RegExp ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) 3. Constructor 1. [ ` RegExp() constructor ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) 4. Static properties 1. [ ` RegExp[@@speci...
Mmdn_RegExp/Regularexpressions_177_0.txt
* The reference pages for [ ` exec() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) , [ ` test() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) , [ ` match() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) , [ ` matchAll() ` ](/en-US/docs/Web/JavaScript/...
Mmdn_RegExp/Mmdn_RegExp_6_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_10_3.txt
er 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_Objects/RegExp/last...
Mmdn_RegExp/Regularexpressions_143_0.txt
const myRe = /d(b+)d/g; const myArray = myRe.exec("cdbbdbsbz"); console.log(`The value of lastIndex is ${myRe.lastIndex}`);
Mmdn_RegExp/Mmdn_RegExp_1_2.txt
ocs/Web/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/__defineGet...
Mmdn_RegExp/exec_139_0.txt
* [ MDN Community ](/en-US/community) * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236) * [ MDN Chat ](/discord)
Mmdn_RegExp/exec_63_0.txt
1. [ References ](/en-US/docs/Web) 2. [ JavaScript ](/en-US/docs/Web/JavaScript) 3. [ Reference ](/en-US/docs/Web/JavaScript/Reference) 4. [ Standard built-in objects ](/en-US/docs/Web/JavaScript/Reference/Global_Objects) 5. [ RegExp ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) 6. [ RegExp.prototy...
Mmdn_RegExp/exec_42_0.txt
Learn to make the web accessible to all
Mmdn_RegExp/toString_46_0.txt
](/en-US/plus)
Mmdn_RegExp/toString_108_0.txt
Your blueprint for a better internet.
Mmdn_RegExp/exec_37_0.txt
](/en-US/docs/Learn/CSS)
Mmdn_RegExp/Regularexpressions_179_0.txt
In the following example, the user is expected to enter a phone number. When the user presses the "Check" button, the script checks the validity of the number. If the number is valid (matches the character sequence specified by the regular expression), the script shows a message thanking the user and confirming the num...
Mmdn_RegExp/exec_132_0.txt
Your blueprint for a better internet.
Mmdn_RegExp/toString_90_0.txt
const foo = new RegExp("bar", "g"); console.log(foo.toString()); // '/bar/g'
Mmdn_RegExp/exec_126_0.txt
Was this page helpful to you?
Mmdn_RegExp/exec_6_0.txt
Structure of content on the web
Mmdn_RegExp/Regularexpressions_65_0.txt
* English (US)
Mmdn_RegExp/Regularexpressions_79_0.txt
## In this article
Mmdn_RegExp/exec_90_0.txt
A [ ` null ` -prototype object ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects) of named capturing groups, whose keys are the names, and values are the capturing groups, or [ ` undefined ` ](/en- US/docs/Web/JavaScript/Reference/Global_Objects/undefined) if no named capturing groups...
Mmdn_RegExp/Mmdn_RegExp_0_4.txt
JavaScript/Reference/Operators/Multiplication_assignment) 48. [ new ](/en-US/docs/Web/JavaScript/Reference/Operators/new) 49. [ new.target ](/en-US/docs/Web/JavaScript/Reference/Operators/new.target) 50. [ null ](/en-US/docs/Web/JavaScript/Reference/Operators/null) 51. [ Nullish coalescing assignment (?...
Mmdn_RegExp/Regularexpressions_99_0.txt
The following pages provide lists of the different special characters that fit into each category, along with descriptions and examples.
Mmdn_RegExp/exec_59_0.txt
* [ Curriculum New ](/en-US/curriculum/) * [ Blog ](/en-US/blog/) * [ Play ](/en-US/play) * [ AI Help Beta ](/en-US/plus/ai-help)