An equivalence class can be used portably within a bracket expression, but only outside the range. If the represented set of collating elements is empty, it is unspecified whether the expression matches nothing, or is treated as invalid. The interpretation of range expressions where the ending range point is also the starting range point of a subsequent range expression for example, "[a-m-o]" is undefined.
To use a hyphen as the starting range point, it shall either come first in the bracket expression or be specified as a collating symbol; for example, "[][. The following rules can be used to construct BREs matching multiple characters from BREs matching a single character:. Subexpressions can be arbitrarily nested. When the referenced subexpression matched more than one string, the back-referenced expression shall refer to the last matched string.
A BRE can be limited to matching strings that begin or end a line; this is called "anchoring". The circumflex and dollar sign special characters shall be considered BRE anchors in the following contexts:. The implementation may treat the circumflex as an anchor when used as the first character of a subexpression. The circumflex shall anchor the expression or optionally subexpression to the beginning of a string; only sequences starting at the first character of a string shall be matched by the BRE.
A portable BRE shall escape a leading circumflex in a subexpression to match a literal circumflex. The implementation may treat a dollar sign as an anchor when used as the last character of a subexpression. The dollar sign shall anchor the expression or optionally subexpression to the end of the string being matched; the dollar sign can be said to match the end-of-string following the last character.
The extended regular expression ERE notation and construction rules shall apply to utilities defined as using extended regular expressions; any exceptions to the following rules are noted in the descriptions of the specific utilities using EREs.
An ERE ordinary character, a special character preceded by a backslash, or a period shall match a single character. An ERE matching a single character enclosed in parentheses shall match the same as the ERE without parentheses would have matched. An ordinary character is an ERE that matches itself. An ERE special character has special properties in certain contexts. Outside those contexts, or when preceded by a backslash, such a character shall be an ERE that matches the special character itself.
The extended regular expression special characters and the contexts in which they shall have their special meaning are as follows:. If these characters appear first in an ERE, or immediately following a vertical-line, circumflex, or left-parenthesis.
The following rules shall be used to construct EREs matching multiple characters from EREs matching a single character:. A concatenation of EREs shall match the concatenation of the character sequences matched by each component of the ERE.
A concatenation of EREs enclosed in parentheses shall match whatever the concatenation without the parentheses matches. Unfortunately, not all programs, commands, and programming languages use the same regular expressions, but they all share similarities. Below are a few examples of regular expressions and pattern matching in Perl. Many of these examples are similar or the same to other programming languages and programs that support regular expressions.
The above example replaces any "bad data" with "good data" using a case-insensitive match. This example replaces any lowercase a with an uppercase A. The above example replaces any lowercase letter, a through z, with an asterisk.
In the above example, we are replacing a period with an exclamation mark. One point to note is that regular expressions are not wildcards.
In this case, it means 'match zero or more 'c' characters followed by a t', so it would match 't', 'ct', 'cccct' etc. Online information often the man pages for UNIX utilities is available by using one of the search engines e. InfoSeek to search for 'regular expressions'. Most characters match themselves. For example, This expression A period.
This expression You can repeat expressions with an asterisk or plus sign. If there is any choice, the first matching string in a line is used. Machine Learning. Data Structures. Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology.
0コメント