Metacharacters of egrep

Metacharacters of egrep

metacharacters in use

Reading Notes

2020.09.22

0 #regex

Summary of the egrep metacharacters1:

Metacharacter   Matches
. dot Matches any one character
[. . .] character class Matches any one character listed
[^. . .] negated character class Matches any one character not listed
\char escaped character When char is a metacharacter, or the escaped combination is not otherwise special, matches the literal char
     
? question One allowed, but it is optional
* star Any number allowed, but all are optional
+ plus At least one required; additional are optional
{min, max} specified range Min required, max allowed
     
^ caret Matches the position at the start of the line
$ dollar Matches the position at the end of the line
\< word boundary Matches the position at the start of a word
\> word boundary Matches the position at the end of a word
     
| alternation Matches either expression it separates
(. . .) parentheses Limits scope of alternation, provides grouping for the quantifiers, and “captures” for backreferences
\1, \2, ... backreference Matches 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.

YOU MAY ALSO LIKE

Using Liquid in Jekyll - Live with Demos

Web Notes

2016.08.20

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

Tools

2020.09.12

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

Tutorials

2020.01.09

Setup an IKEv2 server with StrongSwan

IKEv2, or Internet Key Exchange v2, is a protocol that allows for direct IPSec tunneling between the server and client. 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.