Regex para hacer coincidir frases que no comienzan con [cerrado]

This should be an easy one for the regex masters out there.

I need to match all phrases NOT:
"The smoking areas are located" OR
"The smoking areas are located "

Entrada:

The smoking areas are located
Bla, bla, bla
The smoking areas are in the basement
The smoking areas are located in the back of the building

Partidos:
Bla, bla, bla
The smoking areas are in the basement
The smoking areas are located in the back of the building

preguntado el 09 de marzo de 12 a las 16:03

I've gotten this far:^(!(?=.*?\The\b)(?=.*?\bsmoking\b)(?=.*?\bareas\b)(?=.*?\bare\b)(?=.*?\blocated\b)).*$ -

2 Respuestas

Algo como esto debería funcionar:

^(?!(The smoking areas are located\s?$)).+$

It basically matches anything, given that "The smoking areas are located" doesn't occur. (Negative look ahead)

Thanks to Joseph for pointing out I had missed one of the cases.

respondido 09 mar '12, 16:03

That won't match the last line. You should add a $ to the end of the lookahead: regexr.com?3098k - José Silber

You're absolutely right, I misread the question. - calcao

Perfect. Thanks for your help! - mduchak

Why not just use the equivalent of not mystring.startswith('xyz') in your language of choice? A regex is pretty heavyweight for this kind of operation.

respondido 09 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.