I struggled a bit with coming up with a bash function that wraps Peter Tillemans' answer but here's what I came up with:
function regex { perl -n -e "/$1/ && printf \"%s\n\", "'$1' }
I found this worked better than opsb's awk-based bash function for the following regular expression argument, because I do not want the "ms" to be printed.
'([0-9]*)ms$'