You should `trim` after slicing. There is possible white-space between `|` and start of regular expression (See [edit_spec.coffee](https://github.com/edx/edx-platform/blob/9343ff8b39874bbed7a3754f84785709134a3abc/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee#L351)).