V2EX  ›  英汉词典
Enqueued related words: Backreference, Noncapturing Group

Capture Group

定义 Definition

capture group(捕获组):在正则表达式中,用圆括号 (...) 标记的一部分模式,用来把匹配到的子字符串“捕获/记住”,以便之后通过编号(如 \1)或名称(如 (?<name>...))引用,常用于提取、替换或复用匹配内容。(在不同语言/引擎中细节略有差异;另有“不捕获组”(?:...)。)

发音 Pronunciation (IPA)

/ˈkæptʃər ɡruːp/

例句 Examples

Use a capture group to extract the year from the date string.
使用捕获组从日期字符串中提取年份。

In the replacement, the second capture group is reused to keep the original file extension.
在替换时,会复用第二个捕获组来保留原始的文件扩展名。

词源 Etymology

capture 源自拉丁语 capere(“抓住、获取”),经由法语进入英语;group 源自意大利语 gruppo(“一组、一群”)。合起来在正则表达式语境中表示“把匹配到的一段内容抓取并作为一个组保存起来”。

相关词 Related Words

文学与著作 Literary Works

  • Mastering Regular Expressions(Jeffrey E. F. Friedl)
  • Regular Expressions Cookbook(Jan Goyvaerts, Steven Levithan)
  • Programming Perl(Larry Wall, Tom Christiansen, Jon Orwant)
  • JavaScript: The Definitive Guide(David Flanagan)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2100 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 09:53 · PVG 17:53 · LAX 01:53 · JFK 04:53
♥ Do have faith in what you're doing.