public static Collection<MessageFragmentStyle> colorizeRegex(Style style,String text,Pattern regex,int group){
  ArrayList<MessageFragmentStyle> list=new ArrayList<>();
  Matcher matcher=regex.matcher(text);
  while (matcher.find()) {
    int start=matcher.start(group);
    int end=matcher.end(group);
    if (end - start > 0) {
      MessageFragmentStyle messageFragmentStyle=new MessageFragmentStyle(start,end - start,style,false);
      list.add(messageFragmentStyle);
    }
  }
  return list;
}

public static Collection < MessageFragmentStyle > colorizeRegex ( Style style , String text , Pattern regex , int group ) { ArrayList < MessageFragmentStyle > list = new ArrayList < > ( ) ; Matcher matcher = regex . matcher ( text ) ; while ( matcher . find ( ) ) { int start = matcher . start ( group ) ; int end = matcher . end ( group ) ; if ( end - start > 0 ) { MessageFragmentStyle messageFragmentStyle = new MessageFragmentStyle ( start , end - start , style , false ) ; list . add ( messageFragmentStyle ) ; } } return list ; }
apply styles on styleddocument using regular expression
