<RecordId>12345</RecordId> 只想提取12345

1.grep 速度一般
type myXmlFile.xml|grep -oE "<RecordId>(.*)</RecordId>"|sed "s/<RecordId>//g;s/<\/RecordId>//g"

type myXmlFile.xml|d:\msys\opt\tools\bin\grep -oP "<RecordId>\K\w+"

type myXmlFile.xml|d:\msys\opt\tools\bin\grep -oP "<RecordId>\K\w+(?=</RecordId>)"

零宽断言
type myXmlFile.xml|d:\msys\opt\tools\bin\grep -oP "(?<=<RecordId>).*(?=</RecordId>)" 
                                                   后发断言         先行断言

2.sift 速度较快
type myXmlFile.xml|sift "<RecordId>(.*)</RecordId>" --replace "$1"

3.ripgrep 速度非常快
type myXmlFile.xml|rg "<RecordId>(.*)</RecordId>" -r "$1"

 

相关文章:

  • 2021-11-15
  • 2021-12-19
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
猜你喜欢
  • 2021-07-22
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2021-12-17
  • 2022-02-15
相关资源
相似解决方案