Skip to main content
adicionou 39 caracteres ao conteúdo
Fonte Link
hkotsubo
  • 66,9mil
  • 25
  • 87
  • 170

Existe alguma forma de se combinar múltiplos padrões de regex em um únicouma única expressão, para ser usado no re.match(), ou re.search(), por exemplo?

D      YHR077C NMD2; Nmd2p  K14327 UPF2; regulator of nonsense transcripts 2
D      YGR072W UPF3; Upf3p  K14328 UPF3; regulator of nonsense transcripts 3
D      snR19 SNR19  K14276 U1snRNA; U1 spliceosomal RNA
D      LSR1 LSR1    K14277 U2snRNA; U2 spliceosomal RNA
D      snR14 SNR14  K14278 U4snRNA; U4 spliceosomal RNA
D      snR7-S SNR7-S    K14279 U5snRNA; U5 spliceosomal RNA
D      snR7-L SNR7-L    K14279 U5snRNA; U5 spliceosomal RNA
D      snR6 SNR6    K14280 U6snRNA; U6 spliceosomal RNA
D      snR17a SNR17A    K14483 U3snoRNA; U3 small nucleolar RNA
D      snR17b SNR17B    K14483 U3snoRNA; U3 small nucleolar RNA
D      YHR077C NMD2; Nmd2p  K14327 UPF2; regulator of nonsense transcripts 2
D      YGR072W UPF3; Upf3p  K14328 UPF3; regulator of nonsense transcripts 3
D      snR19 SNR19  K14276 U1snRNA; U1 spliceosomal RNA
D      LSR1 LSR1    K14277 U2snRNA; U2 spliceosomal RNA
D      snR14 SNR14  K14278 U4snRNA; U4 spliceosomal RNA
D      snR7-S SNR7-S    K14279 U5snRNA; U5 spliceosomal RNA
D      snR7-L SNR7-L    K14279 U5snRNA; U5 spliceosomal RNA
D      snR6 SNR6    K14280 U6snRNA; U6 spliceosomal RNA
D      snR17a SNR17A    K14483 U3snoRNA; U3 small nucleolar RNA
D      snR17b SNR17B    K14483 U3snoRNA; U3 small nucleolar RNA

Existe alguma forma de se combinar múltiplos padrões de regex em um único, para ser usado no re.match(), re.search(), por exemplo?

D      YHR077C NMD2; Nmd2p  K14327 UPF2; regulator of nonsense transcripts 2
D      YGR072W UPF3; Upf3p  K14328 UPF3; regulator of nonsense transcripts 3
D      snR19 SNR19  K14276 U1snRNA; U1 spliceosomal RNA
D      LSR1 LSR1    K14277 U2snRNA; U2 spliceosomal RNA
D      snR14 SNR14  K14278 U4snRNA; U4 spliceosomal RNA
D      snR7-S SNR7-S    K14279 U5snRNA; U5 spliceosomal RNA
D      snR7-L SNR7-L    K14279 U5snRNA; U5 spliceosomal RNA
D      snR6 SNR6    K14280 U6snRNA; U6 spliceosomal RNA
D      snR17a SNR17A    K14483 U3snoRNA; U3 small nucleolar RNA
D      snR17b SNR17B    K14483 U3snoRNA; U3 small nucleolar RNA

Existe alguma forma de se combinar múltiplos padrões de regex em uma única expressão, para ser usado no re.match() ou re.search(), por exemplo?

D      YHR077C NMD2; Nmd2p  K14327 UPF2; regulator of nonsense transcripts 2
D      YGR072W UPF3; Upf3p  K14328 UPF3; regulator of nonsense transcripts 3
D      snR19 SNR19  K14276 U1snRNA; U1 spliceosomal RNA
D      LSR1 LSR1    K14277 U2snRNA; U2 spliceosomal RNA
D      snR14 SNR14  K14278 U4snRNA; U4 spliceosomal RNA
D      snR7-S SNR7-S    K14279 U5snRNA; U5 spliceosomal RNA
D      snR7-L SNR7-L    K14279 U5snRNA; U5 spliceosomal RNA
D      snR6 SNR6    K14280 U6snRNA; U6 spliceosomal RNA
D      snR17a SNR17A    K14483 U3snoRNA; U3 small nucleolar RNA
D      snR17b SNR17B    K14483 U3snoRNA; U3 small nucleolar RNA
Fonte Link
user107615
user107615

Combinar múltiplas Expressões Regulares em uma só

Existe alguma forma de se combinar múltiplos padrões de regex em um único, para ser usado no re.match(), re.search(), por exemplo?

starts_with_Y = '([Y][A-Za-z0-9]{6}([-][A-Za-z0-9]{1})?\s)'
starts_with_t = '([t][a-zA-Z][][A-Za-z0-9]{3}[][A-Za-z0-9]([A-Za-z0-9])?\s)'
starts_with_Q = '([Q]\d{4}\s)'
starts_with_RDN = '(\b(\w*RDN\d{1,2}[-]\d\w*)\b)'
starts_with_snR = '(\b(\w*snR\d{1,3}([-][A-Za-z0-9])?\w*)\b[ ])'
starts_with_NME = '(NME\d{1}[ ])'
starts_with_ICR = '(ICR\d{1}[ ])'
starts_with_LSR = '(LSR\d{1}[ ])'

Necessito de um único regex, pois a aplicação faz a leitura de um arquivo de texto linha por linha, e em cada linha aparece apenas um de cada. Exemplo:

D      YHR077C NMD2; Nmd2p  K14327 UPF2; regulator of nonsense transcripts 2
D      YGR072W UPF3; Upf3p  K14328 UPF3; regulator of nonsense transcripts 3
D      snR19 SNR19  K14276 U1snRNA; U1 spliceosomal RNA
D      LSR1 LSR1    K14277 U2snRNA; U2 spliceosomal RNA
D      snR14 SNR14  K14278 U4snRNA; U4 spliceosomal RNA
D      snR7-S SNR7-S    K14279 U5snRNA; U5 spliceosomal RNA
D      snR7-L SNR7-L    K14279 U5snRNA; U5 spliceosomal RNA
D      snR6 SNR6    K14280 U6snRNA; U6 spliceosomal RNA
D      snR17a SNR17A    K14483 U3snoRNA; U3 small nucleolar RNA
D      snR17b SNR17B    K14483 U3snoRNA; U3 small nucleolar RNA

E é possível usar o re.compile() ?