Text-Processing

與 RegEx 的最後一場比賽

  • September 30, 2020

grep -oP '(?<=%28).*?(?=%29)' f.txt在以下行

chr01_pilon_pilon   gmap-gsnap  mRNA    55846944    55847057    .   +   .   ID=NbD052382.1.mrna1;Name=NbD052382.1;Note=cytochrome b6/f complex subunit V %28plastid%29  %28NP_054520.1%29;Parent=NbD052382.1.path1;coverage=100.0;identity=100.0;indels=0;matches=114;mismatches=0;unknowns=0

我明白了plastid%29 %28NP_054520.1%29。怎麼可能只獲得最後一場比賽NP_054520.1

先感謝您

\K您可以用貪婪(“保持左”)斷言替換後向:

$ grep -oP '.*%28\K.*?(?=%29)' f.txt
NP_054520.1

引用自:https://unix.stackexchange.com/questions/612277