How to port this regular expression from JavaScript

Perhaps this could be useful?