REGEX to Select a line containing a drawn string

1

I would like to select a whole line that contains a desired string. For example:

String: "BLUE LED should light"

text:

When pressing the button the BLUE LED should light for 5 seconds according to the test characteristics.

I would like to select the entire line containing the string "BLUE LED should light up" through a Regex that I can use in notepad ++ or python. can anybody help me? Thank you !!

    
asked by anonymous 07.03.2017 / 15:41

1 answer

2

With python it is relatively easy, nor do you need to use regex:

str_desejada = 'LED AZUL deve acender'
for linha in linhas:
    if str_desejada in linha:
        print('existe')

With regex:

import re

linha = 'Ao apertar o botão o LED AZUL deve acender por 5 segundos de acordo com as caracteristicas do teste.'
comp = re.compile('LED AZUL deve acender')
for linha in linhas:
    match = comp.search(linha)
    if match:
        print('existe')
    
07.03.2017 / 16:03