I need a way to perform a preg_match within MySQL. For example:
Whats the best way?
if you would kindly explain what those special characters do, then i'll give it a try
mysql has regular expressions (see REGEXP in da manual) but the tilde (~) is not included
The preg_match I posted above basically searches the string for any numbers and returns true if it finds any.
Basically I have created a search form in PHP and the user has the ability to select "Exclude hyphens" and "Exclude numbers" from search options. When they select Exlude hyphens for example, the search should return only rows that DO NOT contain hyphens. The same applies for numbers.
I am trying something like this, but to no avail:
select * from domains where domain NOT LIKE '^[0-9]+$'
returns true if any numbers are found...
WHERE domain REGEXP '[[:digit:]]'
WHERE domain REGEXP '[0-9]'
returns true if any hyphens are found...
WHERE domain REGEXP '-'
Great, works fine - thank you