public List < MarkupText . SubText > findTokens ( Pattern pattern ) { String text = getText ( ) ; Matcher m = pattern . matcher ( text ) ; List < SubText > r = new ArrayList <> ( ) ; while ( m . find ( ) ) { int idx = m . start ( ) ; if ( idx > 0 ) { char ch = text . charAt ( idx - 1 ) ; if ( Character . isLetter ( ch ) || Character . isDigit ( ch ) ) continue ; // not at a word boundary } idx = m . end ( ) ; if ( idx < text . length ( ) ) { char ch = text . charAt ( idx ) ; if ( Character . isLetter ( ch ) || Character . isDigit ( ch ) ) continue ; // not at a word boundary } r . add ( createSubText ( m ) ) ; } return r ; }
Find all tokens that match the given pattern in this text .