代码之家  ›  专栏  ›  技术社区  ›  AlwaysLearning

PCRE与扩展PCRE的区别

  •  0
  • AlwaysLearning  · 技术社区  · 6 年前

    我有下面的例子 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++ uses the PCRE syntax

    我试着用谷歌搜索这两种语法(Extended和PCRE)之间的差异,但什么也没找到。它们是什么?

    0 回复  |  直到 6 年前