SQL Regular Expressions
If you are a Perl, Python or Java developer, you already know the power of regular expressions. The good news is that Oracle 10g supports regular expressions. The syntax is slightly different from what you may have encountered before but it is very easy to adapt if you are already familiar with regular expression syntax.
Here is a very simple example of extracting the domain name from an e-mail address.
select regexp_substr('sshah@whizdog.com', '@([[:alnum:]]+[_|-|.]*[[:alnum:]]*)') from dual
which results '@whizdog.com' being returned.
For more info, please read this excellent article.
Here is a very simple example of extracting the domain name from an e-mail address.
select regexp_substr('sshah@whizdog.com', '@([[:alnum:]]+[_|-|.]*[[:alnum:]]*)') from dual
which results '@whizdog.com' being returned.
For more info, please read this excellent article.
2 Comments:
I hope I am wrong, but does your sample return domains with more than one dot in it?
Does mymail@mycompany.co.uk work?
Cheers!
Reginald
Good point.
This will pattern will handle domains with more than one dot.
select regexp_substr('mymail@mycompany.co.uk', '@([[:alnum:]]+([_|-|.]*[[:alnum:]]*)*)') from dual
Post a Comment
<< Home