Fill in the input fields below with your regex data and GET your regex, TEST it in real time
We start with 3 regex groups but you can add more(20 more to be precise) if you don't need a group just disable it..
Each group is a part of your search/match text that should have a restrictive nature by itself or its neighbours, it can be that or that but not this nor this.
- Maybe you know something about the begining of your "match text"
you could use the Starts with group, it has an extra option:
- Begining of string or line(if multiline global flag is active)
- Should you know something about the inner text of your "match text"
you could use the Next group.
It has the following CONTENT Type options:
- New line
- White space
- Wildcard *
- Word - sequence
- Wildcard * [] word boundary
- Wequence [] word boundary
- Call backreference by name
And these FLOW Control options:
- Followed by
The default option for the next part of your regex. - ∵) ~ (∴ end group (followed by) new group started here
Break into new capture groups here. - ∵) OR (∴ end group (alternate with) new group started here
Break into new capture groups here and alternate. - AND
Used to join two wildcards* with different options or a backreference with a wildcard* resulting a negative lookahead of the called backreference.
The wildcard* or/and boundary has the following CHARACTERS Group options:
- punctuation _ all punctuation marks
- not whitespace _ non-(new line/tab/cariage return/space)
- a-z _ letters from a to z, lower case
- A-Z _ letters from A to Z, upper case
- 0-9 _ digit from 0 to 9
- not 0-9 _ non-digit
- A-Z0-9
- a-zA-Z
- letter _ a-zA-Z (English/Latin)
- letter _ including any diacritics (Any language)
- not letter _ non-letter (English/Latin)
- not letter _ non-letter (Any language)
- alphanumeric _ a-zA-Z0-9 (English/Latin)
- alphanumeric _ non-special (Any language)
- special _ non-alphanumeric (English/Latin)
- special _ non-alphanumeric (Any language)
- only the characters I will select _ you can choose all allowed characters
- any _ all characters allowed exempt new line(will disable the dotal mode flag for the whole expression)
- any and new line _ all characters including new line(will enable the dotal mode flag for the whole expression)
If you need to include new lines you have to select the Cross new lines(dotal mode) flag.
You can apply more restrictions or enlarge the group further down the road using(Characters group include - characters, Characters group exclude - characters, Characters group(only these) - characters, Will NOT contain - this word/seq, Will contain this word/seq, AND will contain this word/seq).
- If you know something about the end of your "match text"
you could use the Ends with group, it too has an extra option:
- End of string or line(if multiline global flag is active)
Your History
- Last you worked onBrief description
Your History
Execution Map
Notes
1. Always work the Execution Map to make sure you get what you want from your regex.
2. Groups can be joined together using the
Followed by Section
Followed by Section
∴ starts a capture group
∵ ends a capture group
Your Regex..
Preview
What to expect!
With your [Regex] you will be served the following functions: Replace, Match and Callback.
[Test Regex] If you add testing text, the test will execute automatically when you make any changes to your regex or test environment and on loading the page.
[Last Work] Will be updated automatically when you make any changes to your regex but you can also update manually(using the
Hide this.. [Test Regex] If you add testing text, the test will execute automatically when you make any changes to your regex or test environment and on loading the page.
[Last Work] Will be updated automatically when you make any changes to your regex but you can also update manually(using the
round 'U' button
) if you load a regex using a [Regex Url Construction
] and you do not need to make changes to it but you want to save it as last you worked on. Captured groups
Backreference
Named or indexed backreference called within the EXPRESSION..
1. Captured groups can be named using the
Backref Section
2. Then called later in the expression using the
Group Type Section
3. You can call captured groups by their index
Backref Section
?<block_1>
2. Then called later in the expression using the
Group Type Section
\k<block_1>
(as backfererence), block_1 being your chosen name for the captured group /(?<block_1>[0-9]+)(.)+(\k<block_1>)/
3. You can call captured groups by their index
/([0-9]+)(.)+(\1)/
(as backfererence), 1 being the index for the first captured group. * Capturing groups(if they are to be called as backreference) HAVE to be enclosed in round brackets ( group ).
Named or indexed backreference inside the REPLACE..
1. If you need to call the whole match inside the replace you can use $& or $0:
Javascript: var replace = 'some text $& some text';
PHP: $replace = 'some text $0 some text';
2. Index capturing groups can be called inside the replace($1 being the backreference for the first captured group):
Javascript: var replace = 'some text $1';
PHP: $replace = 'some text $1';
3.* Only in JAVASCRIPT named capturing groups can be called inside the replace($<block_1> being the backreference for the named captured group):
var replace = 'some text $<block_1>';
4. Named capturing groups can be called and used inside the callback function, you should have the function served by the server with your regex.
Variables within the EXPRESSION..
1. If you need to call variables inside your regex:
var variable='sweet';
Javascript: var pattern = new RegExp(`(apple )(${variable})( orange)`,'g');
Javascript: var pattern = new RegExp(`(apple )(${variable})( orange)`,'g');
*Note that you cannot replace the backtick( ` ) with any other type of quotes(simple ' or double ") or the expression will fail.
~
$variable='sweet';
PHP: $pattern = '/(apple )('.$variable.')( orange)/g';
PHP: $pattern = '/(apple )('.$variable.')( orange)/g';
Variables inside the REPLACE..
1. If you need to call variables inside the replace, you will concatenate as usual in your programming language:
var variable='sweet';
Javascript: var replace = 'replace text '+variable+' more replace text';
Javascript: var replace = 'replace text '+variable+' more replace text';
~
$variable='sweet';
PHP: $replace = 'replace text '.$variable.' more replace text';
PHP: $replace = 'replace text '.$variable.' more replace text';
Example
Match the outerHTML of any html element(container type, not nesting) using backreference groups. Flags
i
Enables the case-insensitive mode, n and N are viewed as similar.m
Enables the multiline mode, ^ will match the begining of every new line(not just the begining of the string) and $ will match the end of every new line(not just the end of the string).s
Enables the white space dotal mode, should be used to match searchable text cross new lines.g
* Enables the full global search, used in Javascript to continue the search after the first match has been found.Notions (.)+
WILDCARD - ammounts for an unknown quantity of searchable text for which we can set a list of allowed characters, restrict certain characters or sequences/words and set a minimum and/or a maximum length.
CAPTURED - groups represent parts of the searchable text that matched entirely or differents parts of the regular expression being ENCLOSED in ROUND BRACKETS (group).
BACKREFERENCE - holds a reference to a captured group, a handle to that value and can be used later within the expression to balance groups or stipulate unicity or in the replace string and ultimately in the callback function.
BALANCED - groups will match the N(number of occurrences) for group A and B within the searchable text and are generally used to match open and close brackets like "(" and ")" or to match html containers nesting or not. Balanced groups are not integrated in the same manner by all programming languages and more importantly at least in the case of nesting groups the expression will have to rescan within inner layers of all the matched, captured groups slowing the entire execution.
* The best aproach is to handle the balanced groups inside the callback function while deleting the outer layers of all captured groups and record their position/existence.
NON-CAPTURED - groups need to be present within the searchable text in order to have a positive match for the regular expression however they will not be recorded nor present within the returned match.
* Non-captured groups are often uset to mark the boundaries or intermediary states of a regular expression in order to match the inner content of a subgroup or to ignore punctuation and any other unwanted text.
WHITESPACE - Generally the types of whitespace found with regular expressions are the space (\ ), the new line (\n), the tab (\t) and the carriage return (\r). However this special character (\s) will match any of the previous whitespaces.
CAPTURED - groups represent parts of the searchable text that matched entirely or differents parts of the regular expression being ENCLOSED in ROUND BRACKETS (group).
BACKREFERENCE - holds a reference to a captured group, a handle to that value and can be used later within the expression to balance groups or stipulate unicity or in the replace string and ultimately in the callback function.
BALANCED - groups will match the N(number of occurrences) for group A and B within the searchable text and are generally used to match open and close brackets like "(" and ")" or to match html containers nesting or not. Balanced groups are not integrated in the same manner by all programming languages and more importantly at least in the case of nesting groups the expression will have to rescan within inner layers of all the matched, captured groups slowing the entire execution.
* The best aproach is to handle the balanced groups inside the callback function while deleting the outer layers of all captured groups and record their position/existence.
NON-CAPTURED - groups need to be present within the searchable text in order to have a positive match for the regular expression however they will not be recorded nor present within the returned match.
* Non-captured groups are often uset to mark the boundaries or intermediary states of a regular expression in order to match the inner content of a subgroup or to ignore punctuation and any other unwanted text.
WHITESPACE - Generally the types of whitespace found with regular expressions are the space (\ ), the new line (\n), the tab (\t) and the carriage return (\r). However this special character (\s) will match any of the previous whitespaces.