Thread: Reg Ex help!
View Single Post
Old 04-07-2011, 09:42 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,091
You can also pull it off with:

SELECT * FROM `testit` WHERE name RLIKE 'n.* ar.{0,10}$'

The .{0,10} tells it to match any characters up to 10 chars long and the $ tells it that the string should end at that point.

if we just use the .{0,10} it will still match the flagstaff entry because it dose not really care where the string ends.

Or better yet (there were 5 minutes between the last sentence and this ;p) I think what you really want is this:

SELECT * FROM `testit` WHERE name RLIKE 'n.* ar.*[blank]$' Which will tell it to get all characters for the second part of the string that start with 'ar' and go to the first blank space.


From: http://dev.mysql.com/doc/refman/5.5/en/regexp.html

Character Class Name Meaning
alnum Alphanumeric characters
alpha Alphabetic characters
blank Whitespace characters
cntrl Control characters
digit Digit characters
graph Graphic characters
lower Lowercase alphabetic characters
print Graphic or space characters
punct Punctuation characters
space Space, tab, newline, and carriage return
upper Uppercase alphabetic characters
xdigit Hexadecimal digit characters


You could also use [space] instead of blank.
__________________
All cookies cleared!

Last edited by sarettah; 04-07-2011 at 09:45 AM..
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote