Buggy code:
public class PhpRegexpLanguageInjector implements MultiHostInjector { private static final List < String > PREG_METHODS_STRING_ARG = Arrays . asList ( "\\preg_filter" , "\\preg_grep" , "\\preg_match" , "\\preg_match_all" , "\\preg_replace" , "\\preg_replace_callback" , "\\preg_split" ) ; private static final List < String > PREG_METHODS_ARRAY_ARG = Arrays . asList ( "\\preg_filter" , "\\preg_replace" , "\\preg_replace_callback" ) ; @ NotNull @ Override public List < ? extends Class < ? extends PsiElement > > elementsToInjectIn ( ) { } @ Override public void getLanguagesToInject ( @ NotNull final MultiHostRegistrar registrar , @ NotNull final PsiElement element ) { if ( ( ! ( element instanceof StringLiteralExpression ) ) || ( ! ( ( ( PsiLanguageInjectionHost ) ( element ) ) . isValidHost ( ) ) ) ) { return ; } final String regex = ( ( StringLiteralExpression ) ( element ) ) . getContents ( ) ; final int length = regex . length ( ) ; if ( length <= 2 ) { return ; } PsiElement parent = element . getParent ( ) ; boolean skipElement = true ; if ( ( parent instanceof ParameterList ) && ( ( ( ( PhpPsiElement ) ( element ) ) . getPrevPsiSibling ( ) ) == null ) ) { parent = parent . getParent ( ) ; if ( parent instanceof FunctionReference ) { final String fqn = ( ( FunctionReference ) ( parent ) ) . getFQN ( ) ; if ( PhpRegexpLanguageInjector . PREG_METHODS_STRING_ARG . contains ( fqn ) ) { skipElement = false ; } } } else if ( parent instanceof PhpPsiElement ) { parent = parent . getParent ( ) ; if ( ( parent instanceof ArrayCreationExpression ) && ( ( ( ( PhpPsiElement ) ( parent ) ) . getPrevPsiSibling ( ) ) == null ) ) { parent = parent . getParent ( ) ; if ( parent instanceof ParameterList ) { parent = parent . getParent ( ) ; if ( parent instanceof FunctionReference ) { final String fqn = ( ( FunctionReference ) ( parent ) ) . getFQN ( ) ; if ( PhpRegexpLanguageInjector . PREG_METHODS_ARRAY_ARG . contains ( fqn ) ) { skipElement = false ; } } } } } if ( skipElement ) { final char c = regex . charAt ( 0 ) ; if ( ( "!#%&//=@_`|~" . indexOf ( c ) ) >= 0 ) { <START_BUG> skipElement = ! ( regex . matches ( ( ( ( ( ( c + "(?:[^\\\\" ) + c ) + "]+|\\\\.)+" ) + c ) + "[imsuxADSUX]*" ) ) ) ; <END_BUG> } } if ( skipElement ) { return ; } int pos = 0 ; while ( ( pos < length ) && ( PhpRegexpLanguageInjector . isspace ( regex . charAt ( pos ) ) ) ) { pos ++ ; } final char startDelimiter = regex . charAt ( ( pos ++ ) ) ; if ( ( PhpRegexpLanguageInjector . isalnum ( startDelimiter ) ) || ( startDelimiter == '\\' ) ) { return ; } final int startPos = pos ; final char endDelimiter ; switch ( startDelimiter ) { case '(' : endDelimiter = ')' ; break ; case '[' : endDelimiter = ']' ; break ; case '{' : endDelimiter = '}' ; break ; case '<' : endDelimiter = '>' ; break ; default : endDelimiter = startDelimiter ; } int brackets = 1 ; while ( pos < length ) { final char c = regex . charAt ( pos ) ; if ( c == '\\' ) { pos ++ ; } else if ( ( c == endDelimiter ) && ( ( -- brackets ) <= 0 ) ) { break ; } else if ( c == startDelimiter ) { brackets ++ ; } pos ++ ; } if ( pos >= length ) { return ; } final int endPos = pos ; final boolean commentMode = ( regex . indexOf ( 'x' , ( endPos + 1 ) ) ) >= 0 ; final int offset = ( ( StringLiteralExpression ) ( element ) ) . getValueRange ( ) . getStartOffset ( ) ; registrar . startInjecting ( ( commentMode ? PhpRegexpCommentModeLanguage . INSTANCE : PhpRegexpLanguage . INSTANCE ) ) . addPlace ( null , null , ( ( PsiLanguageInjectionHost ) ( element ) ) , TextRange . create ( ( offset + startPos ) , ( offset + endPos ) ) ) . doneInjecting ( ) ; } private static boolean isspace ( final char c ) { } private static boolean isalnum ( final char c ) { } }

Fix:
skipElement = ! ( regex . matches ( ( ( ( ( ( c + "(?>[^\\\\" ) + c ) + "]+|\\\\.)+" ) + c ) + "[imsuxADSUX]*" ) ) ) ;