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.41 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

HTML 相对路径和绝对路径区别分析

Web Notes

2015.09.26

HTML 相对路径和绝对路径区别分析

HTML 初学者会经常遇到这样一个问题,如何正确引用一个文件。比如,怎样在一个 HTML 网页中引用另外一个 HTML 网页作为超链接(hyperlink),怎样在一个网页中插入一张图片。如果你在引用文件时(如加入超链接,或者插入图片等),使用了错误的文件路径,就会导致引用失效(无法浏览链接文件,或无法显示插入的图片等)。

Using Liquid in Jekyll - Live with Demos

Web Notes

2016.08.20

Using Liquid in Jekyll - Live with Demos

Liquid is a simple template language that Jekyll uses to process pages for your site. With Liquid you can output complex contents without additional plugins.

Understanding Nginx location directive

Tools

2020.09.12

Understanding Nginx location directive

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 less unpredictable.