@@ -622,18 +622,21 @@ private String highlightSearchBold(String text, String search) {
622622 }
623623
624624 private String highlightSearch (String text , String search , String before , String after ) {
625+ String [] terms = search .split (" " );
625626 String output = new String (text );
626- List <Integer > res = new ArrayList <>();
627- for (int index = output .toLowerCase ().indexOf (search ); index >= 0 ;
628- index = output .toLowerCase ().indexOf (search , index + 1 )) {
629- res .add (index );
630- }
631- for (int i = res .size ()-1 ; i >= 0 ; i --) {
632- int index = res .get (i );
633- output = output .substring (0 , index ) + before
634- + output .substring (index , index + search .length ())
635- + after
636- + output .substring (index + search .length (), output .length ());
627+ for (String term : terms ){
628+ List <Integer > res = new ArrayList <>();
629+ for (int index = output .toLowerCase ().indexOf (term ); index >= 0 ;
630+ index = output .toLowerCase ().indexOf (term , index + 1 )) {
631+ res .add (index );
632+ }
633+ for (int i = res .size ()-1 ; i >= 0 ; i --) {
634+ int index = res .get (i );
635+ output = output .substring (0 , index ) + before
636+ + output .substring (index , index + term .length ())
637+ + after
638+ + output .substring (index + term .length (), output .length ());
639+ }
637640 }
638641 return output ;
639642 }
0 commit comments