Download Day Day Up > Classic Shell Scripting By Nelson H.F. Beebe
Transcript
This way, you don't have to worry about whether a single quote or double quote was found first.
3.2.2.3 Matching multiple characters with one expression
The simplest way to match multiple characters is to list them one after the other (concatenation). Thus, the regular e
matches the characters ab , .. (dot dot) matches any two characters, and [[:upper:]][[:lower:]] matches any u
character followed by any lowercase one. However, listing characters out this way is good only for short regular exp
Although the . (dot) metacharacter and bracket expressions provide a nice way to match one character at a time, the
regular expressions comes into play when using the additional modifier metacharacters. These metacharacters come
character regular expression, and they modify the meaning of the regular expression.
The most commonly used modifier is the asterisk or star (* ), whose meaning is "match zero or more of the precedin
character." Thus, ab*c means "match an a , zero or more b characters, and a c ." This regular expression matches ac
abbbc , and so on.
It is important to understand that "match zero or more of one thing" does not mean "match one of s
else." Thus, given the regular expression ab*c , the text aQc does not match, even though there are
characters in aQc . Instead, with the text ac , the b* in ab*c is said to match the null string (the str
zero width) in between the a and the c . (The idea of a zero-width string takes some getting used to
never seen it before. Nevertheless, it does come in handy, as will be shown later in the chapter.)
The * modifier is useful, but it is unlimited. You can't use * to say "match three characters but not four," and it's ted
type out a complicated bracket expression multiple times when you want an exact number of matches. Interval expre
problem. Like * , they come after a single-character regular expression, and they let you control how many repetitio
character will be matched. Interval expressions consist of one or two numbers enclosed between \{ and \} . There a
as follows:
\{ n \}
Exactly n occurrences of the preceding regular expression
\{ n ,\}
At least n occurrences of the preceding regular expression
\{ n ,m \}
Between n and m occurrences of the preceding regular expression
Given interval expressions, it becomes easy to express things like "exactly five occurrences of a ," or "between 10 a
q ." To wit: a\{5\} and q\{10,42\} .
The values for n and m must be between 0 and RE_DUP_MAX , inclusive. RE_DUP_MAX is a symbolic constant defined b
available via the getconf command. The minimum value for RE_DUP_MAX is 255; some systems allow larger values. O
GNU/Linux systems, it's quite large:
Related documents
Programmierung
L+_LJF.1L
master`s thesis submission form - Seidenberg School of Computer
User Manual
zsh: Power Tools. Because having all your
Checking for Race Conditions in File Accesses
V400-F050/250/350 2D Code Reader User's Manual
V400-F050/250/350 2D Code Reader User`s Manual
USER`S MANUAL
Rich Control Applications User Manual
CQ5 WCM User Guide - Adobe Experience Manager 6.1