Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
-
Gurzi
- Forum Commoner
- Posts: 27
- Joined: Wed Aug 02, 2006 4:04 pm
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
-
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?
+- , i want the word without numbers..
i have tiago and tiago87, i want to retrieve tiago
-
stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Post
by stereofrog »
or
both match strings that don't contain any numbers. The second one is locale-aware.