Linux Regular Expressions - Wildcards

  

Wildcard metacharacters or periods (.) are considered equivalent to variables. A variable represents any value in an arithmetic expression. In regular expressions, a period (.) is a wildcard that represents any character other than a newline character (in awk, a period can even match an embedded newline character).

Suppose we are describing a sequence of characters, using wildcard metacharacters to specify a location where any character can be filled. For example, if you want to retrieve a discussion file containing an Intel system microprocessor, use the following regular expression: 80.86 will match the line containing the sequence "80286,", "80386," or "80486.". In order to match a decimal point or a period, you must escape the "spot" with a backslash.

Matching any character at the beginning or end of a pattern is useless. Therefore, wildcard characters are usually placed before or after characters or other metacharacters. For example, the regular expression written below searches for a sequence of chapters: chapter. It searches for <; 'chapter' followed by a string of arbitrary characters”. In some searches, this expression may have the same match as the fixed string pattern "chapter". Take a look at the following example:
$grep 'Chapter.' sampleyou will find several examples in Chapter 9."Quote me ' Chapter and Verse' ," she said.Chapter Ten

"chapter" matches the string, and using "chapter" will also match the same line. However, there is a different situation if one "chapter" appears at the end of the line.

Copyright © Windows knowledge All Rights Reserved