PCRE和扩展之间的区别

时间:2019-03-12 18:48:16

标签: regex grep notepad++ pcre

我有以下示例适用于扩展grepsed

grep -E --color '^L' input.txt
grep -E --color 'L$' input.txt

grep -E --color '02-?2' input.txt
grep -E --color '2+' input.txt
grep -E --color '22+' input.txt
grep -E --color '222?' input.txt
grep -E --color 'AAA*' input.txt
grep -E --color 'A{3}' input.txt
grep -E --color 'A{2,}' input.txt
grep -E --color 'A{2,3}' input.txt

grep -E --color '(^Re|him|AL$)' input.txt
grep -E --color '^(Re|him|AL)' input.txt
grep -E --color '(Re|him|AL)$' input.txt

grep -E --color '[1-9]{8,}' input.txt
grep -E --color '[12390]{8,}' input.txt
grep -E --color '0[1-9]-[^57]{7,}' input.txt
grep -E --color '0.-[0-9]+' input.txt
grep -E --color '0.-[0-9z]+' input.txt

grep -E --color 'a[[:space:]]+0' input.txt
grep -E --color '[^[:digit:][:space:]]{5,}' input.txt

sed -E 's/^[[:alpha:]]+/Name/g' input.txt
sed -E 's/^([[:alpha:]]+)[[:space:]]*(0.)/Name: \1\tPhone: \2/g' input.txt

输入文件为:

Reuven  02-2342312  AAAABB
Shimon  08-8156831  AACDEF
Levi    03-639z387  UYGnAL
Yehuda  022221938   UYGnBL
The period. Another period.

我在nodepad++中尝试了相同的搜索和替换,希望自nodepad++ uses the PCRE syntax起,至少有一些搜索和替换会失败。但是他们都工作了。

我试图用谷歌搜索两种语法(扩展语法和PCRE)之间的差异,但没有找到任何东西。这些是什么?

0 个答案:

没有答案