static boolean matchBackward ( char [ ] chars , char [ ] pattern , int [ ] cursor ) { int start = cursor [ 1 ] - pattern . length ; if ( start < cursor [ 0 ] ) // candidate is too short to possibly match return false ; if ( ! matchForward ( chars , pattern , new int [ ] { start , cursor [ 1 ] } ) ) return false ; // The candidate matches, so reflect that in the cursor cursor [ 1 ] = start ; return true ; }
Match characters in a backward direction