OS X's sed doesn't have "-r", so switched to using Bash's regex