protected static String orRegex ( Iterable < String > elements ) { final StringBuilder regex = new StringBuilder ( ) ; for ( final String element : elements ) { if ( regex . length ( ) > 0 ) { regex . append ( "|" ) ; //$NON-NLS-1$ } regex . append ( "(?:" ) ; //$NON-NLS-1$ regex . append ( quoteRegex ( element ) ) ; regex . append ( ")" ) ; //$NON-NLS-1$ } return regex . toString ( ) ; }
Build a regular expression that is matching one of the given elements .