Различия между PCRE и расширенным - PullRequest
0 голосов
/ 12 марта 2019

У меня были следующие примеры работы с расширенным grep и с sed:

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++ использует синтаксис PCRE . Однако все они работали.

Я пытался найти в Google различия между двумя синтаксисами (расширенный и PCRE), но ничего не нашел. Кто они такие?

...