Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2008, 10:58 AM
mavoric mavoric is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 64 mavoric User rank is Lance Corporal (50 - 100 Reputation Level)mavoric User rank is Lance Corporal (50 - 100 Reputation Level)mavoric User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 45 m 41 sec
Reputation Power: 9
Caret symbol accepted

Please tell me if I'm wrong, but shouldn't the following regex query identify only the letters a-z A-Z 0-9 and space?

^([A-z 0-9]*)$

used in a php context

Code:
!ereg("^([A-z 0-9]*)$", $string)


I want it to pick out when characters other than a-z, 0-9 and space's are used. However it is allowing the caret symbol through

^

Just so i know its not my php environment screwed up, i tried it here...
http://www.fileformat.info/tool/regex.htm

using ^([A-z 0-9]*)$

and the following strings

Code:
dfvfd45t54
srfdfcdf
^fdvdf

and that was doing the same. Am i missing out on something here?

Thanks in advance for any replies

Reply With Quote
  #2  
Old November 4th, 2008, 05:45 PM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 36 m 34 sec
Reputation Power: 3885
Note you've used a capital A and a lowercase z.

That means accept any character from ASCII code 66 (A) to ASCII code 122 (z). Since the caret character is code 94, it's one of the ones included.

If you want to cover both upper- and lowercase letters, you have to separate them, i.e.:
Code:
^([A-Za-z 0-9]*)$

Reply With Quote
  #3  
Old November 5th, 2008, 08:02 AM
mavoric mavoric is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 64 mavoric User rank is Lance Corporal (50 - 100 Reputation Level)mavoric User rank is Lance Corporal (50 - 100 Reputation Level)mavoric User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 45 m 41 sec
Reputation Power: 9
ahh ok, I used that method as it was recommended on a few websites. I now know not to.

Thanks very much

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Caret symbol accepted

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap