I have:
- A
stringwith valuewww.facebook.com - A column
allowed_domainwith valuefacebook.com
I try to see if the domain string (with subdomains) matches the column (without subdomain) as such:
SELECT * FROM MyTable
WHERE 'www.facebook.com' REGEXP '^([a-zA-Z0-9]+\.)*' + allowed_domain + '$'
The string “www.facebook.com” is extracted from the referrer in my actual code.
You can see the regexp I’m using in action here
My problem is that the regexp isn’t matching in MySql. What’s wrong with it?
Found the solution here: Using Columns in a RegExp in MySQL. I needed to send a single string object into the regexp as such: