Regular Expressions In GeDit

6.2k views Asked by At

I need to find some syntax for the seeking for the simple patterns within the txt document open via GeDit.

In particular my file consist of data like

>|hOR1G1|/1-313
FMVMALTGTGVVSFFT
>|hOR1B1|/1-317
FYGVTIEGLMCVGYIT
>|hOR1E1|/1-314 
FLGDSLMGILFVSYIT
>|hOR1D2|/1-31
LVVANLTGIFFVSYCT
>|hOR1A1|/1-309
MIGNSLGVIFLVSYMT
>|hOR1A2|/1-309
MIAKSLGVVFLVFYMT

Here I need to select /1-313 in each of the headers and remove it from the each odd string of the list which will looks like

>|hOR1G1|
FMVMALTGTGVVSFFT
>|hOR1B1|
FYGVTIEGLMCVGYIT
>|hOR1E1|

Could someone suggest me syntax of RE implemented in GeDit as well as some tutorial focused on such tasks?

2

There are 2 answers

0
Gilles Quénot On

gedit seems not the right tool for this, or will be better here, so:

perl -pe 's@/\d+-\d+$@@g' file.txt

or

sed -r 's@/[0-9]+-[0-9]+$@@g' file.txt

and if you want to replace in-line, add the -i switch.

2
Casimir et Hippolyte On

In gedit:

search: /\d+-\d+

replacement: nothing

check the regex checkbox and replace all.