Page 1 of 1

find the word without number

Posted: Sat Apr 14, 2007 1:10 pm
by Gurzi
hello, im learning regex but i have one doubt at this moment..

i have one string with two words.

tiago87
tiago

and i want to find the word without numbers

i thougt that the pattern was

[^a-z0-9]

Where i am wrong ?

can you tell me the right way ?

thanks

Posted: Sat Apr 14, 2007 1:23 pm
by aaronhall
I believe /^[a-zA-Z]+$/ will only match strings without numbers or special characters

Posted: Sat Apr 14, 2007 1:30 pm
by Gurzi
yes , you are right.

But i want to learn to use the ^(negation of)

If anyone know , please help..


Thanks

Posted: Sat Apr 14, 2007 1:49 pm
by nickvd
Well, this ([^a-z0-9]) is saying, match everything except the characters a-z and 0-9.

You want everything except for numbers, correct?

Posted: Sat Apr 14, 2007 1:54 pm
by Gurzi
nickvd wrote:Well, this ([^a-z0-9]) is saying, match everything except the characters a-z and 0-9.

You want everything except for numbers, correct?
8O

+- , i want the word without numbers..

i have tiago and tiago87, i want to retrieve tiago

Posted: Sat Apr 14, 2007 1:57 pm
by Benjamin

Code: Select all

#^([a-z]{1,50})#i

Posted: Mon Apr 16, 2007 6:14 am
by stereofrog

Code: Select all

/^[^0-9]*$/
or

Code: Select all

/^\D*$/
both match strings that don't contain any numbers. The second one is locale-aware.