regexp refactor for rails4

regexp refactor for rails4