Manipulación simple de cadenas Regex

Just a simple question. I am wondering how to write a regex expression for the phrase 'Ste 5800 Bldg 10 Ste A'.

I would like it to handle both the numeric values and the letter values after the wordphrase. I am just having trouble doing that. I have '\w+\s\d+, but i do not know how to include the letter values.

The end result should be 'Ste 5800','Bldg 10','Ste A'.

preguntado el 28 de mayo de 14 a las 14:05

Can you say which letters are fixed ? -

I think this will answer it. I want to only capture multiple digits and singular letters such that I want the regex to capture 'Ste A' but not "Ste Aspect". Is that good? -

2 Respuestas

Demo en vivo

Prueba esto:

(\w+) (\d+|[a-zA-Z])\b

contestado el 28 de mayo de 14 a las 18:05

It does not match the strings he wants - el3ien

yup, I forgot the parenthesis. - CMPS

guys I have another question lol, would you want me to ask here on the comments or on a new question all together? - user3683871

@user3683871 New question please :) - CMPS

Esto debería hacer el trabajo.

'Ste 5800','Bldg 10','Ste A'.

\w+\s[\d\w]+

If you want to search for 'Ste A' but not 'Ste Aspect'

\b\w+\s\d+|\b\w+\s\w\b

contestado el 28 de mayo de 14 a las 17:05

Thanks! and what if i wanted to only capture multiple digits and singular letters such that I want the regex to capture 'Ste A' but not "Ste Aspect"? - user3683871

are there allways ' or " at the end or spaces? - el3ien

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