JavaScript正则表达式匹配成对出现的标记(平衡组-balanced group)

XRegExp.matchRecursive(str, left, right, [flags], [options])

Requires the XRegExp.matchRecursive addon, which is bundled in xregexp-all.js.

Returns an array of match strings between outermost left and right delimiters, or an array of objects with detailed match parts and position data. An error is thrown if delimiters are unbalanced within the data.

Parameters:
  • str {String}
    String to search.
  • left {String}
    Left delimiter as an XRegExp pattern.
  • right {String}
    Right delimiter as an XRegExp pattern.
  • [flags] {String}
    Any combination of XRegExp flags, used for the left and right delimiters.
  • [options] {Object}
    Lets you specify valueNames and escapeChar options.
Returns:
  • {Array}
    Array of matches, or an empty array.

Example

参考链接


发布者

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注