Other Resources:
Pattern groups (...)
What is pattern group? What are pattern groups used for?
How to write a regular expression using groups to capture character names from the Ed, Edd 'n' Eddy animated comedy television series?
✍: FYIcenter.com
The grouping mechanism allows a part of a regex to be treated as a single unit. A group is represented by regular expression pattern enclosed in parentheses like this: (...).
Groups can be used to capture sub strings in a matched pattern. For example:
\D*(\d+).* # a group to capture the first string of digits \W*(\w+).* # a group to capture the first word
Groups can be used to limit a logical OR operation. For example:
(Mon|Sun)day.* # Excluding 'day.*' from the 'Mon|Sun' operation
Groups can also be nested to form a complex groups. For example:
house(cat(s|)|) # matches house, housecat or housecats
The regular expression to capture all Ed, Edd and Eddy is:
Ed(d(y|)|)
(y|) - inner group to match 'y' or nothing
(d(...)|) - outer group to match 'd(...)' or nothing
2013-01-23, 0👍, 0💬
Popular Posts:
How to capture the Sogou web spider entries from Web log file? Here are some Web log file entries: 1...
How to capture the Baidu spider entries from Web log file? Here are some Web log file entries: 127.0...
How to capture the Sogou web spider entries from Web log file? Here are some Web log file entries: 1...
According to the IEEE 802 specification, a MAC address has 6 groups of 2 hexadecimal digits separate...
How to capture the Sogou web spider entries from Web log file? Here are some Web log file entries: 1...