# Regular Expression - Group (Capture|Substitution)

Construct Definition (?X)``` | X, as a named-capturing group | ^ non-capturing ^^ | (?:X) | X, as a non-capturing group | | (?>X) | X, as an independent, non-capturing group | ^ Assertion (See Regexp - Look-around group (Assertion) - ( Lookahead | Lookbehind )) ^^ | (?=X) | X, positive lookahead (via zero-width) | | (?!X) | X, negative lookahead (via zero-width) | | (?<=X) | X, positive lookbehind (via zero-width) | | (?<!X) | X, negative lookbehind (via zero-width) | ^ Flag ^^ | (?idmsuxU-idmsuxU) | Nothing, but turns match flags i d m s u x U on - off | | (?idmsux-idmsux:X) | X, as a non-capturing group with the given flags i d m s u x on - off | ===== Name ===== By default, the group is indexed by index (0,1,2,…) but you can give it a name with the following syntax (?X)where X is the regular expression pattern that you want to captureIt's called a named-capturing group.IndexCapturing groups are numbered by counting their opening parentheses from left to right. In the expression ((A)(B(C))), for example, there are the following groups: 0 - Group zero always stands for the entire expression - ((A)(B(C))) 1 - ((A)(B(C))) 2 - (A) 3 - (B(C)) 4 - (C) Non-CapturingBasicA non capturing group will not be indexed.In the expression (?:A)(B)(C), for example, there are the following groups: 0 - Group zero always stands for the entire expression - (?:A)(B)(C) 1 - (B) 2 - (C) The group (?:A) was not captured.Look-aroundRegexp - Look-around group (Assertion) - ( Lookahead | Lookbehind )SubstitutionWhen you want to use the content of each captured group, you will generally use the following substitution construct: n for the group index groupName for the group name When using group index, this construct must be used when: the number of group is greater than 9 you want a number that follow the substitution The dollar is also not always mandatory: n for the group index groupName for the group name Their is also a shorthand notation for groups up to 9. Symbol Definition \0 backreference to the entire expression \1 backreference to group 1 \2 backreference to group 2 \n backreference to group n ExampleThe below regular expression has two groups ([^ ]) (.*) where: the first group is [^ ] which will parse all non space characters. the second group is .* which will take all characters. if you parse the following text: Hello World You will get: in the first group, \1, the text Hello and in the second group, \2, the text World See more example here: Examples on how to replace a text in Notepad++ with regular expression```
``` ```
``` Discover MoreAutomata - Automaton LibraryThis page lists state machine libraries. All regular expression library implements an automaton. We list a couple of example. : Finite-state automaton for regular... Examples on how to replace a text in Notepad++ with regular expressionA step by step tutorial and snippets on how to replace a portion of text in notepad++ with regular expression How to get Started With FluentBitFluentBit from Calyptia is a log collector (ie observability pipeline tool) (written in C, that works on Linux and Windows). It's the Fluentd successor with smaller memory footprint When you need... How to use Regular expression (Regexp) in Javascript?This page is regular expression in Javascript code unitssingle-character pattern (.) The pattern enclosed between slashes. Loaded compilation (only when the script is loaded) Runtime compilation... How to use Regular expression (regex) in Bash?This article shous you how to use regular expression in Bash This example shows you how you can capture a Group to extract text. Example where we will extract a part of a file name When the... Java - Regular ExpressionThe Regular Expression implementation in Java is based on PCRE. See the comparison to perl section on the java/util/regex/Patternpattern regular expression page Regular expressions are managed within... Multilingual Regular Expression Syntax (Pattern)Regular expression are Expression that defines a pattern in text. This is therefore a language that permits to define structure of a text. They are a mathematically-defined concept, invented by Stephen... Nginx - Location blockA location block is a block that is located inside a server block and maps a a resource path to a destination path such as: a local directory or an other service (see ) A server block may have several... PHP - StringThe string in PHP is implemented as an array of bytes with the ascii character set and an integer indicating the length of the buffer. It has no information how those bytes translate to characters, leaving... Php - Regular expressions (Perl-compatible)in Php are an implementation of Perl (PCRE) with the PCRE library (See ). Therefore, the syntax for patterns used in these functions closely resembles to Perl (PCRE) but not totally. See reference.pcre.pattern.differencesPerl... Share this page: Follow us: ```
``` ```
``` Data (State) Data (State) DataBase Data Processing Data Quality Data Structure Data Type Data Warehouse Data Visualization Data Partition Data Persistence Data Concurrency Data Science Data Analysis Statistics Data Science Linear Algebra Mathematics TrigonometryModeling Process Logical Data Modeling Relational Modeling Dimensional Modeling Automata Data Type Number Time Text Collection Relation (Table) Cube Tree Key/Value Graph Spatial Color Log Measure Levels Order Nominal Discrete Distance Ratio Code Compiler Lexical Parser Grammar Function Testing Debugging Shipping Data Type Versioning Design Pattern Infrastructure Operating System Monitoring Cryptography Security File System Network Process (Thread) Computer Infra As Code Marketing Advertising Analytics Email Web Html Dom Http Url Css Javascript Selector Browser Web Services OAuth Contact [email protected] Privacy Policy Status ```