April 8th, 2009, 10:21 AM
Helo with REGEX ......Substitute for SQL Like
Hello peeps ........REGEX is officially that part of programming my brain is just not going to have to master. Got a simple problem.
Supposing that I have a word "pine"
I then want to do a REGEX check against a word so that if it starts with "pine" return true.
eg. check("pineapple") will return true
check ("pinacolada") will return false.
check ("monthend") will return false.
check("pinebottle") will return true.
Something like how in SQL you do a LIKE 'PINE%'
April 8th, 2009, 11:42 AM
This will only match if it's the *first* word of the string you're matching it on though. If it's in the middle of a string somewhere, you could just use the word pine, but that would mean it also matches words like randompinerandom which is not what you're looking for.
*edit* I just thought of something else as well, which would make it match anywhere in the string, as long as the word starts with pine. This won't match if it is the first word in the string though because it matches a space before the word: \spine