I’m a bit confused on the functionality of the REGEX support for MySQL and I have yet to find a solid example on how to separate a result with REGEX within an sql statement.
Example:
How could I pull data from a table emails that looks something like…
+-------------------------+
|Emails |
|-------------------------|
|Some.email@yourDomain.com|
+-------------------------+
and return something through an sql statement that looks like…
+------------------------------+
|Username | Domain | TLD |
|-----------|------------|-----|
|some.email | yourdomain | com |
+------------------------------+
MySQL doesn’t have built-in functionality to do what you’re asking for. It would be possible by defining some new functions, but it’s probably easier to just do it in whatever programming language you’re accessing the database through.
For something as simple as an email address though, you shouldn’t need to use regular expressions at all, you can use the
SUBSTRING_INDEX()function, as:In words, that’s: