Two Pointer Algorithm Javascript Substring Function In Oracle