public int findIn ( Source source ) { if ( source . hasNext ( ) ) { // maybe we are on the beginning of line already? if ( onBol ( source ) ) { return source . getOffset ( ) ; } // If no find next line break int index = findLineBreak ( source ) ; if ( index < 0 ) { return - 1 ; } // Skip line break 1 or 2 characters index = skipLineBreak ( source , index ) ; // If index is not on the end of text return it otherwise it's not a beginning of line. if ( index < source . length ( ) ) { return index ; } else { return - 1 ; } } else { return - 1 ; } }
I strongly don t recommend to use tag bol as a terminator .