Artificial intelligent assistant

last match with RegEx I do `grep -oP '(?<=%28).*?(?=%29)' f.txt` on the following line 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 and I get `plastid%29 %28NP_054520.1%29`. How is it possible to get the last match only `NP_054520.1`? Thank you in advance

You could replace the lookbehind with a greedy `\K` ("keep left") assertion:


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

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 888b9dae35c651ac52c5811c958f1ac4