private Pattern compile ( final String tagIdentifiers , final boolean ignoreCase ) { try { String [ ] tags ; if ( tagIdentifiers . indexOf ( ' ' ) == - 1 ) { tags = new String [ ] { tagIdentifiers } ; } else { tags = StringUtils . split ( tagIdentifiers , "," ) ; } List < String > regexps = new ArrayList < String > ( ) ; for ( int i = 0 ; i < tags . length ; i ++ ) { String tag = tags [ i ] . trim ( ) ; if ( StringUtils . isNotBlank ( tag ) ) { StringBuilder actual = new StringBuilder ( ) ; if ( Character . isLetterOrDigit ( tag . charAt ( 0 ) ) ) { actual . append ( WORD_BOUNDARY ) ; } actual . append ( tag ) ; if ( Character . isLetterOrDigit ( tag . charAt ( tag . length ( ) - 1 ) ) ) { actual . append ( WORD_BOUNDARY ) ; } regexps . add ( actual . toString ( ) ) ; } } int flags ; if ( ignoreCase ) { flags = Pattern . CASE_INSENSITIVE ; } else { flags = 0 ; } return Pattern . compile ( "^.*(" + StringUtils . join ( regexps . iterator ( ) , "|" ) + ")(.*)$" , flags ) ; } catch ( PatternSyntaxException exception ) { isInvalidPattern = true ; errorMessage . append ( Messages . Tasks_PatternError ( tagIdentifiers , exception . getMessage ( ) ) ) ; errorMessage . append ( "\n" ) ; return null ; } }
Compiles a regular expression pattern to scan for tag identifiers .