Quick Tip: Oracle REGEXP_REPLACE

I’ve always thought of regular expressions as party tricks used at a Magna Cum Laude party at MIT. I still do. Regular expressions are a mystery wrapped in enigma and set in a field shrouded in a thick mental fog. Unfortunately, I occasionally need to venture into that party in the foggy field to retrieve a domain name from a URL for example.

select REGEXP_REPLACE('https://mail.somedomain.com/flippyWidgets','.+:\/\/([^/]+).*', '\1') from dual

You can also do this in JavaScript…

var url = "https://mail.somedomain.com/flippyWidgets/index.html?unread=954";


Leave a Reply