Bash Regex String

This regular expression pattern is very useful to implement a strong and complex password. I've been using the following regex below in a bash script on RHEL 5. We have selected a set of commands we think will be useful in general to a wide range of audience. (It does not seem to be written into [bash] [man] page. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH. In response to Aquarius Power in the comment above, We need to store the regex on a var. These too are subsumed by features of POSIX shells, except for one: expr STRING : REGEXP tests whether the string matches the specified regexp. Comparison operators are operators that compare values and return true or false. bash documentation: Get captured groups from a regex match against a string. A "regular expression" is a text string that describes a particular search pattern. One of the most used feature is to match two or more, multiple string, patterns or regex. Any command-line expert knows the power of regular expressions. Unlike the Bash shell in Linux which only works with strings, with PowerShell, we work with. By default, sed reads the file line by line and changes only the first occurrence of the SEARCH_REGEX on a line. GitHub Gist: instantly share code, notes, and snippets. substr STRING POSITION LENGTH Returns the substring of STRING beginning at POSITION with length at most LENGTH. I'm attempting to remove both the [and ] characters in one fell swoop, i. the last capture. In this article, let us review how to use the parameter expansion concept for string manipulation operations. Conventionally, a shellscript should start with a line such as the following: #!/bin/bash. RIP Tutorial. (POSIX allows either behavior. How do I use the grep command with regular expressions on a Linux and Unix-like operating systems? How do I use grep and regular expressions to search for text/ words in Linux? Linux comes with GNU grep, which supports extended regular expressions. bash / shell / terminal / cli In this tutorial, you will be introduced to the command line. On the other hand I do not need the power of regular expressions: I just need to substitute the text literally. One of the most important things about regular expressions is that they allow you to filter the output of a command or file, edit a section of a text or configuration file and so on. It is a program which scans a specified file line by line, returning lines that contain a pattern matching a given regular expression. The fundamental building blocks are the regular expressions that match a single character. Syntax : if ; then elif ; then else fi Learn the syntax and usage of else if in conjunction with if statement, with the help of Example Bash Scripts. Unfortunately, these tools lack a unified focus. RegEx with sed (bash script) submitted 2 years ago * by Patrick_the_Saint I am working on a script to parse (excuse me if this is the wrong term) text and remove bits and pieces of it. With the strings below, try writing a pattern that matches only the live animals (hog, dog, but not bog). Resources for more detailed study of the BASH command Linux Shell Scripting Tutorial @ Cyberciti. It could be the beginning of a variable name, or it could be part of a regular expression. The "Character Class Ranges" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. This article is part of the on-going bash tutorial series. shell/bash generate random alphanumeric string. This is not intended to teach programming, etc. Regular expressions are constructed analogously to arithmetic expressions by using various operators to combine smaller expressions. Regular expressions are implemented in the grep command (and its siblings) in bash (found in Cygwin on Windows and Terminal on OSX) and in grep() and its siblings in R. $_ is the variable containing the line, the=~ operator tells perl to evaluate the regex on the content of the variable. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH. They can help you in pattern matching, parsing, filtering of results, and so on. To keep with script programming paradigm and allow for better math support, languages such Perl or Python would be better suited when math is desired. Any command-line expert knows the power of regular expressions. Putting one of these in a regex tells the regex engine to try to match a single character. Regular expression is used to : (1) test a string whether it matches a pattern, such as a email address. In this article, we will show you several ways to check if a string contains a substring. With this incredible tool you can: Validate text input Search (and replace) text within a file Batch rename files Undertake incredibly powerful searches for files Interact with servers like Apache Test for patterns within strings […]. Using += : Append to variable. Fortunately the grouping and alternation facilities provided by the regex engine are very capable, but when all else fails we can just perform a second match using a separate regular expression - supported by the tool or native language of your choice. cut and tr to trim a string. Linux bash provides a lot of commands and features for Regular Expressions or regex. The term "Regular Expression" is usually abbreviated to regex or regexp. substr STRING POS LENGTH: substring of STRING, POS counted from 1. They can be used to search, edit, or manipulate text and data. – AFH Sep 26 '14 at 11:27. Hello everybody, I'm clearly not an expert in bash scripting as I've written maybe less than 10 scripts in my life. Bash provides string operations. Something like "ifeelfat398poundsand15ounces. # Awk numbers first character of string as '1'. Domain names: This regular expression tests the validity of a domain or hostname. Tagged as: Tags Bash, bash case in esac, bash if. There are many string comparisons that can be made using Bash. In this chapter, we will discuss in detail about regular expressions with SED in Unix. Avoid nasty surprises when using a regular expression to modify real data or files. In the introduction, we stated that grep stands for "global regular expression print". How you can compare the string values in bash is shown using various examples in this tutorial. Strings have a match method to match them against a regular expression and a search method to search for one, returning only the starting position of the match. It will replace all occurrences of the regular expression with the replacement string inside the file. An array is a variable containing multiple values may be of same type or of different type. The "Character Class Ranges" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. In an earlier article, we discussed the various ways of how to extract a sub-string from every line in a file. A regular expression is a pattern that is matched against a subject string from left to right. A number of complex tasks can be solved with simple regular expressions. Extract substring using regexp in plain bash. Hi, I know that I should use =~ to match regex (bash version 4). Do be aware in the 2nd example above, that, in the bash shell, the =~ is a binary operator, and everything to the right is a regular expression. GitHub Gist: instantly share code, notes, and snippets. length STRING: length of STRING. match() method to test an expression on a string. Networking With Bash; Parallel; Pattern matching and regular expressions; Behaviour when a glob does not match anything; Case insensitive matching; Check if a string matches a regular expression; Extended globbing; Get captured groups from a regex match against a string; Matching hidden files; Regex matching; The * glob; The ** glob; The ? glob. Identify String Length inside Bash Shell Script ${#string} The above format is used to get the length of the given bash. Operator Syntax Description Example eq INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2 #!/bin/bash read -p "Please enter and confirm number 10 via keyboard : " n. The period / dot is a special character in regex, you have to escape it either with a double backlash \\. Refer to our earlier article on bash { } expansion. This session introduces you to the basics of regular expressions. Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript Regular Reg Expressions Ex 101. (POSIX allows either behavior. Introduction [] What is Bash? [Bash is a "Unix shell": a command line interface for interacting with the operating system. Once you learn the regex syntax, you can use it for almost any language. " in a character range. In addition to doing simple matching, bash regular expressions support sub-patterns surrounded by parenthesis for capturing parts of the match. This was just a. That means, simple bash scripts with pipes can work _much_ faster than single scripts in Python or Perl. 3 - Bash Binary operator When the additional regexp binary operator =~ is used, the string to the right of the operator is considered an extended regular expression and matched accordingly (as in regex(3)). More information about regex command cna be found in the following tutorials. Zytrax Tech Stuff - Regular Expressions - A Gentle Introduction, Intermediate User Guide and Tutorial. The regex equivalent is «. Import the regex module with import re. Options to the read built-in 10. If you know just a little about them, a quick-start introduction is available in perlrequick. Your question is confusing: you can either have an exact match (stings are identical) or you can have a regex match (string matches the template in a regular expression). Let's look for the letter "l" in the string. GNU, which is an acronym for "GNU's Not Unix", is a project that strives to provide the world with free and open implementations of all the tools that are commonly available on Unix systems. Certain tools use regular expressions to take these patterns and do something with them. Regular Expressions. Just enter your regex in the field below, press Generate Text button, and you get random data that matches your regular expression. It is not possible to use another single quote within two single quotes not even if the single quote is escaped by backslash. A single character is represented with a ?. The variables we used in those scripts are called as 'Scalar Variables' as they can hold only a single value. Bash supports a surprising number of string manipulation operations. These too are subsumed by features of POSIX shells, except for one: expr STRING : REGEXP tests whether the string matches the specified regexp. Vasya regex valid packaging slug string between quotes + nested quotes Strip non-digits URLquery string adjuster Replace Path Matching for TireRack Match integers clean UnsignedWithoutU Url html parse LastName-Processing RegEx Allowing Number Only veeam Success. Introduction [] What is Bash? [Bash is a "Unix shell": a command line interface for interacting with the operating system. MySQL REGEXP performs a pattern match of a string expression against a pattern. substr STRING POS LENGTH: substring of STRING, POS counted from 1. I'm trying to strip an xml string removing every tag in it. Here a listed few of many ways how to extract number from a string. Another useful form of parameter expansion is to expand a variable and do string substitution on the value using the form ${VAR/search/replace}. Networking With Bash; Parallel; Pattern matching and regular expressions; Behaviour when a glob does not match anything; Case insensitive matching; Check if a string matches a regular expression; Extended globbing; Get captured groups from a regex match against a string; Matching hidden files; Regex matching; The * glob; The ** glob; The ? glob. or even more sophisticated ones based on regex, sed…. Regular expressions should be used for more complex tests. Once you learn the regex syntax, you can use it for almost any language. A string is any finite sequence of characters, and it can be as few as one character. Note that only the first instance of the search string is replaced, if you want to replace all instances use a double slash:. Regular Expression Flags; i: Ignore case: m ^ and $ match start and end of line: s. Regular expressions are constructed analogously to arithmetic expressions by using various operators to combine smaller expressions. It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the dictionary as individual arguments using the *args and **kwargs syntax. But i need a single regular expression which will accept either of the formats. For example, you can match tar pattern using the following syntax:. Regular Expressions Cheat Sheet from DaveChild. If the * character is used at the end of the wildcard string, the number of characters matched depends on the settings for wildcard match lengths. I am going to show how you can make a PowerShell script executable directly from Bash. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions. You know that the input will be a valid HTML file, so the regular expression does not need to exclude any invalid use of sharp brackets. In this article, let us review 15 various. LOOP Does not split string words (not extended regular expression). The matches are assigned to an array variable BASH_REMATCH. Networking With Bash; Parallel; Pattern matching and regular expressions; Behaviour when a glob does not match anything; Case insensitive matching; Check if a string matches a regular expression; Extended globbing; Get captured groups from a regex match against a string; Matching hidden files; Regex matching; The * glob; The ** glob; The ? glob. An address can be a line number (such as 1, 5, 37, etc. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. Url Validation Regex | Regular Expression - Taha nginx test Blocking site with unblocked games Extract String Between Two STRINGS special characters check Match anything enclosed by square brackets. This Regular Expressions tutorial is divided into 3 sections. A string is any finite sequence of characters, and it can be as few as one character. Quote these special characters to match them literally:. Regular expressions are constructed analogously to arithmetic expressions by using various operators to combine smaller expressions. Hello everybody, I'm clearly not an expert in bash scripting as I've written maybe less than 10 scripts in my life. # Awk numbers first character of string as 1. A string either matches a regular expression or it doesn't - there is no approximate match. vformat (format_string, args, kwargs) ¶. Features of Regular Expression. In this article, let us review 15 various. Something like "ifeelfat398poundsand15ounces. This page describes the syntax of regular expressions in Perl. com is hosted on Liquid Web, a perfect hosting provider, 100% uptime and 24 hours support. Testing for a full match. The element of BASH_REMATCH with index n is the portion of the string matching the nth parenthesized. The combination of parameter expansion and regex operators can make bash. Comparison operators are operators that compare values and return true or false. Manipulating Strings. The most basic usage of the grep command is to search for a string (text) in a file. To use extended regular expressions in Cygwin, run egrep or pass the -E flag (note that it's upper-case). Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH. Identify String Length inside Bash Shell Script ${#string} The above format is used to get the length of the given bash. Regular Expressions. To scan ahead to find a string pattern, type "/" and enter a regular expression to match. 1 No lines were selected. In this article, let us review 15 various. 2(1)-release I assume there's been alot of changes to bash since that's quite a jump in revisions (12 Replies). SunOS and other 'expr''s treat these as regular characters. Zytrax Tech Stuff - Regular Expressions - A Gentle Introduction, Intermediate User Guide and Tutorial. Where did you read it first. The above regular expression matches “alex”. Tags: Bash, linux, match, matching, pattern, regex, regular expressions, sh, string, substring 9 There are a few ways to find out if a string contains a substring using bash. Strings have a match method to match them against a regular expression and a search method to search for one, returning only the starting position of the match. To formulate the expression, I used information from the Bash Guide for Beginners which states that: Two regular expressions may be joined by the infix operator "|"; the resulting regular expression matches any string matching either subexpression. AWK has the following built-in String functions − asort(arr [, d [, how] ]) This function sorts the contents of arr using GAWK's normal rules for comparing values, and replaces the indexes of the sorted values arr with sequential integers starting with 1. Return an iterator which yields the same values as glob() without actually storing them all simultaneously. Using += : Append to variable. Create a Regex object with the re. There is many ways to do string manipulation with bash, like finding a filename extension using expr, separating the directory part from a filename using dirname and basename…. txt to find all text files in a file manager. The Documentary. One of the most used feature is to match two or more, multiple string, patterns or regex. It returns 0 (success) if the regular expression matches the string, otherwise it returns 1 (failure). Here's an interesting regex problem: I seem to have stumbled upon a puzzle that evidently is not new, but for which no (simple) solution has yet been found. And don't quote it, either -- or else it will be treated as a literal string. The first step is to make sure that you install PowerShell. Here's what you'd learn in this lesson: James introduces characters classes, which commands Regular Expressions to match several sets of characters. g - Global replacement flag. To split string in Bash with multiple character delimiter use Parameter Expansions. Suppose you want to use a regex to match an HTML tag. How do I escape a dot / period in bash string match. tr is one of the most basic applications to pipe data through that uses a basic scripting syntax. Regular expressions (regex) are similar to Glob Patterns, but they can only be used for pattern matching, not for filename matching. What am I missing?. Isearch, that is, incremental search, is the standard way to search in vanilla Emacs. What this page shows you is, given a certain regex, the Perl syntax to write one-liners to accomplish various tasks. , man grep. You can still take a look, but it might. Some are a subset of parameter substitution, and others fall under the functionality of the UNIX expr command. A regex is a text string that describes a pattern that a regex engine uses in order to find text (or positions) in a body of text, typically for the purposes of validating, finding, replacing or splitting. A regular expression is a pattern that describes a set of strings. If you need more general tutorial about regex please look following article. Capturing groups are saved in the array variable BASH_REMATCH with the first element, Group 0, representing the entire expression. For compatibility with all versions of Bash from 3. One can test that a bash variable starts with a string or character in bash efficiently using any one of the following. MySQL REGEXP performs a pattern match of a string expression against a pattern. (2) to find a substring which matches certain pattern, from a whole text. g - Global replacement flag. Regular expressions, or “regex” are a very powerful tool for searching and processing text. To escape a string for use as a command line argument in Bash, simply put a backslash in front of every non-alphanumeric character. To check if two strings are equal in bash scripting, use bash if statement and double equal to == operator. In this tutorial we will look how to add or concatenate strings in Linux bash. A regular expression enclosed in slashes (`/') is an awk pattern that matches every input record whose text belongs to that set. An array is a variable containing multiple values may be of same type or of different type. 10-digit phone number with hyphens match whole word Find Substring within a string that begins and ends with paranthesis Simple date dd/mm/yyyy all. or uses the Pattern. One of the most used feature is to match two or more, multiple string, patterns or regex. At a high level, regular expressions are a way of defining patterns of text to operate on. Regular expressions are a very powerful tool in Linux. /X functions the same as having both ^ at the beginning and $ at the end of a regex search string. In this tutorial on Bash scripting, we are going to learn to do comparisons. les utilitaires Linux suivants acceptent également du regex. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH. Zytrax Tech Stuff - Regular Expressions - A Gentle Introduction, Intermediate User Guide and Tutorial. Regular Expression Library provides a searchable database of regular expressions. "alexa?" Some characters have special meanings in a regular expression. Regular expressions (shortened as "regex") are special strings representing a pattern to be matched in a search operation. Bash has its own regular expression engine since version 3. 1 No lines were selected. 3)Extended Regular expressions (Use option -E for grep and -r for sed) Some FAQ's before starting Regular expressions. Examples have been provided for Bash Split String operation. Learning Regular Expressions. They are an important tool in a wide variety of computing applications, from programming languages like Java and Perl, to text processing tools like grep, sed, and the text editor vim. To Concatenate Strings in Bash, use one of the following techniques. bash how to trim string. We will be discussing numeric, strings & file comparisons in a Bash script. How to check for a matching pattern in bash? Ask Question Browse other questions tagged bash regex or ask your own question. egrep is an acronym for "Extended Global Regular Expressions Print". Setting the -x tells Bash to print out the statements as they are being executed. This power tip covers UltraEdit's legacy and Unix style regular expressions with several examples. A regular expression, regex or regexp (sometimes called a rational expression) is a sequence of characters that define a search pattern. If there is no match, the return value is an empty string, but it will also be empty if the regular expression successfully matches an empty string. Just enter your regex in the field below, press Generate Text button, and you get random data that matches your regular expression. For instance, one could have the following pattern : 2 digits, 2 letters and 4 digits. When you want to search and replace specific patterns of text, use regular expressions. And while I'm comparing glob patterns to regular expressions, there's an important point to be made that may not be immediately obvious: glob patterns are just another syntax for doing pattern matching in general in bash. An array is a variable containing multiple values may be of same type or of different type. The target sequence is either s or the character sequence between first and last, depending on the version used. g - Global replacement flag. How to Split String with a Delimiter in Bash Script Written by Rahul, Updated on November 17, 2017. No ads, nonsense or garbage. Bash regex =~ matching multiple strings? - posted in Bash / Shell Scripting: I have a bash regex/scripting problem that Im trying to solve that involves using bashs builtin regex. If set to true, enable --extended-regexp option by default. Regular expressions are a powerful means for pattern matching and string parsing that can be applied in so many instances. Regular expressions are a standardized way to express patterns to be matched against sequences of characters. txt textfiles/ moves (mv) all files with names ending in. "When it is used, the string to the right of the operator is considered an extended regular expression and matched accordingly (as in regex(3))". 3)Extended Regular expressions (Use option -E for grep and -r for sed) Some FAQ's before starting Regular expressions. For example, the Unix Bash shell command mv *. What is a Regular expression? A regular expression is a concept of matching a pattern in a given string. For instance, one could have the following pattern : 2 digits, 2 letters and 4 digits. The blue text is the regular expression and the text below it is what we are testing it on. /X functions the same as having both ^ at the beginning and $ at the end of a regex search string. A string either matches a regular expression or it doesn't - there is no approximate match. f can be fetched by: ?44. Match string not containing string Check if a string only contains numbers Match elements of a url Validate an ip address Match an email address Match or Validate phone number Match dates (M/D/YY, M/D/YYY, MM/DD/YY, MM/DD/YYYY) Empty String Match html tag Checks the length of number and not starts with 0 Not Allowing Special Characters Match a. If you're still leaning on grep and sed commands to get your scripts. hello I want to do a pattern match for string in the if statement, but I am not sure how to use regex inside the if statement. 5 using version GNU bash, version 3. Comparing Strings using "if" Testing Strings. Networking With Bash; Parallel; Pattern matching and regular expressions; Behaviour when a glob does not match anything; Case insensitive matching; Check if a string matches a regular expression; Extended globbing; Get captured groups from a regex match against a string; Matching hidden files; Regex matching; The * glob; The ** glob; The ? glob. 2(1)-release I assume there's been alot of changes to bash since that's quite a jump in revisions (12 Replies). A substantial number of regular expression metacharacters are supported, but not some of the Perl-specific extensions like \w, \d and \s. A regular expression (or RE) specifies a set of strings that matches it; the functions in this module let you check if a particular string matches a given regular expression (or if a given regular expression matches a particular string, which comes down to the same thing). If you are like me and like doing the same then maybe you will find this useful. This chapter covers standard regular expressions with suitable examples. Bash: Check that string is IP. One of the most common operations when working with strings in Bash is to determine whether or not a string contains another string. So if you are Bash Scripting or creating a Python program, we can use regex or we can also write a single line search query. fi, bash substring, BourneShell substring, echo usage, pdf files, regular expressions, shell Substring, string comparison Cool Linux penguin shirt. FINDSTR - Escapes and Length limits - More detail of how to use search strings that include quotes and/or backslashes. bash/terminal/sh is a shell that interacts with your file system and can execute programs. Special bash variables 3. You can donate as little as $1 to support nixCraft: Become a Supporter Make a contribution via Paypal/Bitcoin. The element of BASH_REMATCH with index n is the portion of the string matching the nth parenthesized. Raw Python strings. Conventionally, a shellscript should start with a line such as the following: #!/bin/bash. I have an issue with bash and its regex match ability that I for now think is a bug in bash but could also be me having missed something obvious. These are a pattern matching system that uses strings constructed according to pre-defined syntax rules to find desired patterns in text. , man grep. One of the most used feature is to match two or more, multiple string, patterns or regex. Extended Regular Expressions. If you use bash for scripting you will undoubtedly have to use conditions a lot, for example for an if … then construct or a while loop. You can test these examples I am about to walk through in a number of places. grep comes from the ed command to print all lines matching a certain pattern g/re/p where "re" is a "regular expression". Regular Expression Flags; i: Ignore case: m ^ and $ match start and end of line: s. Part of the problem is lookahead matching -- I want to match the whole string if it meets these criteria rather than the first part of the string that doesn't match. Active 3 years, Yes I know this regex is not very good, but I'd. If you're looking for the exact match on the whole string as in your example, you can use [code bash]==[/code]: [code bash] # matches "count" only if [[ ";$tmp". The period / dot is a special character in regex, you have to escape it either with a double backlash \\. Regular expressions (regex) are similar to Glob Patterns, but they can only be used for pattern matching, not for filename matching. In case it matters for flavors, this is going into a bash script on Debian. Start of String and End of String Anchors. So in total $_=~/^V/ evaluates TRUE when The string in $_ begins with V. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab (6 Replies). Find and replace a string using regular expressions. it automatically saved as a string based on IFS values separator. From here onwards I will illustrate regular expressions as above. #!/bin/bash # substring-extraction. I've recently written about using bash arrays and bash regular expressions, so here's a more useful example of using them to test IP addresses for validity. Options to the declare built-in 12. If either POSITION or LENGTH is negative. true if string matches the regular expression regexp. biz Introduction to BASH Programming @ Tldp. This operator matches the string that comes before it against the regex pattern that follows it. Regular expression is used to : (1) test a string whether it matches a pattern, such as a email address. The capturing parentheses you see in a pattern only capture a single group. REGEXP operator. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH. 2013-05-10 • Marios Zindilis. Shell script variables are by default treated as strings, not numbers, which adds some complexity to doing math in shell script. Suppose you want to use a regex to match an HTML tag. Replacing a Substring of Unknown Position Or Length in Perl. length is 2 and the max. GNU grep is the default on all Linux systems. grep , expr , sed and awk are some of them. Notice the Perlish "=~" syntax and that the regular expression appears within double brackets. The matches are assigned to an array variable BASH_REMATCH. First, we need to. Different applications and programming languages implement regular expressions slightly differently. The set consists of a combination of characters and symbols which when used in a group, convey a special meaning. Complete python 3 Tutorials (2018) in Hindi. com is hosted on Liquid Web, a perfect hosting provider, 100% uptime and 24 hours support. BASH Scripting aanndd RREEGGEEXX bbaassiiccss FFrreeddLLUUGG HHooww ttoo ddeemmyyssttiiffyy BBAASSHH aanndd RREEGGEEXX Peter Larsen September 27, 2014 Sr. Tagged as: Tags Bash, bash case in esac, bash if. One of the most used feature is to match two or more, multiple string, patterns or regex. A regular expression, specified as a string, must first be compiled into an instance of this class. say you have a file, test. Operator Syntax Description Example eq INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2 #!/bin/bash read -p "Please enter and confirm number 10 via keyboard : " n. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH.