Php mysql búsqueda de expresiones regulares para no números en lugar de espacios

SELECT object_nm FROM `objects` WHERE `object_nm` REGEXP '[^0-9]*Vasil[^0-9]*[^0-9]Levski[^0-9]*[^0-9]1[^0-9]*'

what i want is to search for 'Vasil levski 1' with only letters (any length) allowed between words.

preguntado el 31 de enero de 12 a las 08:01

"only letters allowed between words" doesn't make sense to me. Do you mean you want to search for 'Vasil' AND 'levski' AND '1' and only return results that have all three of those strings AND only have letters (no numbers OR spaces?) between words? -

search for these words and allow only letters and spaces between words. -

haría VasilLevski1 be a valid match? -

Yes, also Vasil sdfasdf Levski asdkjad 1 or VasillllLevskiiii1 is valid. But Vasil Levski 11 is not valid -

1 Respuestas

Qué tal esto:

^[[:alpha:] ]*Vasil[[:alpha:] ]*Levski[[:alpha:] ]*1[[:alpha:] ]*$


^              # Start of string
[[:alpha:] ]*  # Any number of letters or spaces
Vasil          # Vasil
[[:alpha:] ]*  # Any number of letters or spaces
Levski         # etc.
[[:alpha:] ]*
[[:alpha:] ]*
$              # until end of string

Respondido el 31 de enero de 12 a las 12:01

for some reason it doesn't work as i perfectly. But it's a help. I will play with these regexp and post if/when i come to a solution. 10x very much. - m4r71n

it gives me about 10 founds and should give me over 400 - m4r71n

@m4r71n: I have updated the regex according to your comment above. - Tim Pietzcker

It worked! Thanks, seems i didn't rewrote it right. 10x again. - m4r71n

i had an idea for even better results, may i ask u how to make it like: ^ [[:alpha:] ]*WORD[[:alpha:] ]?[:anything:][[:alpha:] ]?WORD[[:alpha:] ]* $ - m4r71n

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