find the word without number

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Gurzi
Forum Commoner
Posts: 27
Joined: Wed Aug 02, 2006 4:04 pm

find the word without number

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

I believe /^[a-zA-Z]+$/ will only match strings without numbers or special characters
Gurzi
Forum Commoner
Posts: 27
Joined: Wed Aug 02, 2006 4:04 pm

Post by Gurzi »

yes , you are right.

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

If anyone know , please help..


Thanks
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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?
Gurzi
Forum Commoner
Posts: 27
Joined: Wed Aug 02, 2006 4:04 pm

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

#^([a-z]{1,50})#i
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post 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.
Post Reply