当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

match

优质
小牛编辑
124浏览
2023-12-01

Creates a Sequence comprising all of the matches for the specified pattern in the underlying string.

Signature

StringLikeSequence.match = function(pattern) { /*...*/ }
StringLikeSequence.match = function match(pattern) {
  return new StringMatchSequence(this, pattern);
}
NameType(s)Description
patternRegExp

The pattern to match.

returnsSequence

A sequence of all the matches.

Examples

Lazy("abracadabra").match(/a[bcd]/) // sequence: ["ab", "ac", "ad", "ab"]
Lazy("fee fi fo fum").match(/\w+/)  // sequence: ["fee", "fi", "fo", "fum"]
Lazy("hello").match(/xyz/)          // sequence: []