---
title: "正则表达式中括号的三种功能"
author: "mywebcode"
date: "2011-12-01T22:38:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2013-05-08T10:14:26Z"
id: 1862494
url: "https://mywebcode.iteye.com/blog/1862494"
---

正则表达式中括号的三种功能：

1)限定多选结构的范围； 如：ab(c|d|e)fgh，注意上述写法与去掉括号时 abc|d|efgh 的区别

2)标注量词作用的元素；如：ab(cde)+fgh，注意上述写法与去掉括号时 abcde+fhg的区别

3)为引用捕获文本；作为这个用法加括号是为了返回或引用匹配结果