static private boolean isNoncapturingParen(String s,int pos){
  boolean isLookbehind=false;
{
    String pre=s.substring(pos,pos + 4);
    isLookbehind=pre.equals("(?<=") || pre.equals("(?<!");
  }
  return s.charAt(pos + 1) == '?' && (isLookbehind || s.charAt(pos + 2) != '<');
}

static private boolean isNoncapturingParen ( String s , int pos ) { boolean isLookbehind = false ; { String pre = s . substring ( pos , pos + 4 ) ; isLookbehind = pre . equals ( "(?<=" ) || pre . equals ( "(?<!" ) ; } return s . charAt ( pos + 1 ) == '?' && ( isLookbehind || s . charAt ( pos + 2 ) != '<' ) ; }
determines if the parenthesis at the specified position of a string is for a non - capturing group , which is one of the flag specifiers ( e . g . , ( ? s ) or ( ? m ) or ( ? : pattern ) . if the parenthesis is followed by " ? " , it must be a non - capturing group unless it ' s a named group ( which begins with " ? < " ) . make sure not to confuse it with the lookbehind construct ( " ? < = " or " ? < ! " ) .
