Metacharacters of egrep

Metacharacters of egrep

metacharacters in use

Summary of the egrep metacharacters1:

Metacharacter Matches
.dotMatches any one character
[. . .]character classMatches any one character listed
[^. . .]negated character classMatches any one character not listed
\charescaped characterWhen char is a metacharacter, or the escaped combination is not otherwise special, matches the literal char
?questionOne allowed, but it is optional
*starAny number allowed, but all are optional
+plusAt least one required; additional are optional
{min, max}specified rangeMin required, max allowed
^caretMatches the position at the start of the line
$dollarMatches the position at the end of the line
\<word boundaryMatches the position at the start of a word
\>word boundaryMatches the position at the end of a word
|alternationMatches either expression it separates
(. . .)parenthesesLimits scope of alternation, provides grouping for the quantifiers, and “captures” for backreferences
\1, \2, ...backreferenceMatches text previously matched within first, second, etc., set of parentheses

not supported by all versions of egrep

There’re three types of escaped items:

  1. The pairing of \ and a metacharacter is a metasequence to match the literal character (for example, \* matches a literal asterisk).
  2. The pairing of \ and selected non-metacharacters becomes a metasequence with an implementation-defined meaning (for example, \< often means “start of word”).
  3. The pairing of \ and any other character defaults to simply matching the charater literal (that is, the backslash is ignored).
  1. Friedl, Jeffrey E. F. Mastering Regular Expressions. 3rd ed. Sebastapol, CA: O’Reilly, 2006. 

Ads by Google


Frank Lin

Hey, there! This is Frank Lin (@flinhong), one of the 1.4 billion 🇨🇳. This 'inDev. Journal' site holds the exploration of my quirky thoughts and random adventures through life. Hope you enjoy reading and perusing my posts.


Using Liquid in Jekyll - Live with Demos

Web Notes


Using Liquid in Jekyll - Live with Demos

Liquid is a simple templating language that Jekyll uses to process pages on your site. With Liquid you can output an modify variables, have logic statements inside your pages and loop over content.

Understanding Nginx location directive



Understanding Nginx location directive

Nginx location directives are essential when working with Nginx. They can be located within server blocks or other location blocks. Understanding how location directives are used to process the URI of client request can help make the request handling seem less unpredictable.

Setup an IKEv2 server with StrongSwan



Setup an IKEv2 server with StrongSwan

IKEv2, or Internet Key Exchange v2, is a protocol that allows for direct IPSec tunneling between two points. In IKEv2 implementations, IPSec provides encryption for the network traffic. IKEv2 is natively supported on some platforms (OS X 10.11+, iOS 9.1+, and Windows 10) with no additional applications necessary, and it handles client hiccups quite smoothly.