I've never used them, but Howard wrote some wrapper UDFs for RegExp which does exactly what you want. See this link:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=2&Number=76617

I had my own way of doing it, but cannot seem to find it right now...