zoukankan      html  css  js  c++  java
  • 正则表达式零宽断言 grep sift ripgrep(rg)

    <RecordId>12345</RecordId> 只想提取12345
    
    1.grep 速度一般
    type myXmlFile.xml|grep -oE "<RecordId>(.*)</RecordId>"|sed "s/<RecordId>//g;s/</RecordId>//g"
    
    type myXmlFile.xml|d:msysopt	oolsingrep -oP "<RecordId>Kw+"
    
    type myXmlFile.xml|d:msysopt	oolsingrep -oP "<RecordId>Kw+(?=</RecordId>)"
    
    零宽断言
    type myXmlFile.xml|d:msysopt	oolsingrep -oP "(?<=<RecordId>).*(?=</RecordId>)" 
                                                       后发断言         先行断言
    
    2.sift 速度较快
    type myXmlFile.xml|sift "<RecordId>(.*)</RecordId>" --replace "$1"
    
    3.ripgrep 速度非常快
    type myXmlFile.xml|rg "<RecordId>(.*)</RecordId>" -r "$1"
  • 相关阅读:
    bzoj2959
    学习笔记::lct
    bzoj3203
    bzoj1319
    bzoj3625
    bzoj3992
    bzoj1565
    bzoj3513
    平常练习动归(1.胖男孩)———最长公共子序列
    2016 noip 复赛 day2
  • 原文地址:https://www.cnblogs.com/nlsoft/p/13551693.html
Copyright © 2011-2022 走看看