There is a package which does this: https://github.com/joddie/pcre2el