@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    SessionState ss = SessionState.get();
    if (ss != null) {
      this.useGoogleRegexEngine = ss.getConf().getBoolVar(HiveConf.ConfVars.HIVE_USE_GOOGLE_REGEX_ENGINE);
    }

    checkArgsSize(arguments, 2, 2);

    checkArgPrimitive(arguments, 0);
    checkArgPrimitive(arguments, 1);

    checkArgGroups(arguments, 0, inputTypes, STRING_GROUP);
    checkArgGroups(arguments, 1, inputTypes, STRING_GROUP);

    obtainStringConverter(arguments, 0, inputTypes, converters);
    obtainStringConverter(arguments, 1, inputTypes, converters);

    if (arguments[1] instanceof ConstantObjectInspector) {
      regexConst = getConstantStringValue(arguments, 1);
      if (regexConst != null) {
        if(!useGoogleRegexEngine){
          //if(!HiveConf.getVar(hiveConf, HiveConf.ConfVars.HIVE_USE_GOOGLE_REGEX_ENGINE)){
          patternConst = Pattern.compile(regexConst);
        }else{
          patternConstR2j = com.google.re2j.Pattern.compile(regexConst);
        }
      }
      isRegexConst = true;
    }

    ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    return outputOI;
  }
UDF to extract a specific group identified by a java regex. Note that if a
regexp has a backslash ('\'), then need to specify '\\' For example,
regexp_extract('100-200', '(\\d+)-(\\d+)', 1) will return '100'
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFRegExp.java