Problem:
I want to get all records that contain a subdomain.
Some subdomains are saved prefixed with www. after the http://, but not all are.
Examples:
http://www.sub.domain.com and http://sub.domain.com
I have this working regex that I have tested on RegExr:
^(http:\/\/)(www\.)?(\w)+(\.)(\w)+(.)(\w|\/){2,10}
Which matches both examples nicely.
However when I try using this regex in my query using REGEXP, mysql returns 0 records.
I have tried:
SELECT * FROM `front` WHERE `domain` REGEXP '^(http:\/\/)(www\.)?(\w)+(\.)(\w)+(\.)(\w|\/){2,10}$';
SELECT * FROM `front` WHERE `domain` REGEXP '/^(http:\/\/)(www\.)?(\w)+(\.)(\w)+(\.)(\w|\/){2,10}$/';
SELECT * FROM `front` WHERE `domain` REGEXP '/^(http:\/\/)(www\.)?(\w)+(\.)(\w)+(\.)(\w|\/){2,10}$/g';
Which all return 0 records.
TL;DR
My working REGEX does not seem to be working when used in MySQL's REGEXP function.