Advertisement
728x90
The purpose of exec method is similar to test method but it executes a search for a match in a specified string and returns a result array, or null instead of returning true/false.
javascript
1var pattern = /you/;
2
3console.log(pattern.exec("How are you?")); //["you", index: 8, input: "How are you?", groups: undefined]Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 76
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
161of476