Match method
String.prototype.match is a JavaScript string method that matches a string against a regular expression and returns match information or null if no match is found.
The Well-Grounded Rubyist, Fourth Edition
A match is an operation that tests whether text satisfies a regular expression and may return information about the match.
- How it is used
- Tests strings against regular expressions when code needs either a conditional result or details of a successful match.
- How deep it goes
- Works through success, failure, captures, and result access, without descending into the matching engine.
- Examples
- Uses a captured phone number, a conditional search for `la`, and an array filter for long strings containing digits.
- What you can do after
- Apply it via Ruby’s `Regexp#match` to guard failed searches and retrieve matched text and captures.
Read how The Well-Grounded Rubyist, Fourth Edition explains match method →
Secrets of the JavaScript Ninja, Second Edition
A JavaScript method that searches a string with a regular expression and returns match information.
- How it is used
- Uses regular-expression searches to determine whether a string matches and retrieve matching text or captures.
- How deep it goes
- Explains result arrays for local and global searches, including capture behavior, and defers referencing captures within the regex.
- Examples
- Uses an HTML string to compare matching tags locally and globally, then searches them with exec.
- What you can do after
- Understand how local and global regular-expression searches differ in returned matches and captures.
Read how Secrets of the JavaScript Ninja, Second Edition explains match method →
Related concepts
- arrayproduces · An array is an indexed, ordered collection of elements arranged in one or more dimensions, with elements accessed by position.
- regular expressionuses · A formal pattern notation that describes sets of strings and enables text to be matched, searched, extracted, or transformed.
- MatchDataproduces · MatchData is a Ruby object containing the results, captured substrings, and locations associated with a regular-expression match.
- missing valueproduces · A missing value is a marker or condition indicating that an expected data value or reference is absent, unavailable, unknown, or inapplicable.
- global regular expressionused by · A JavaScript regular expression with the g flag, which enables successive matching across a string.
- regex groupingcontrasts with · A regex capturing group is a parenthesized regular-expression subpattern whose matched text is retained for separate access or reference.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

