Change str.indexOf(rx) to rx.indexIn(str)