private static String[] preProcessArgs(String[] unprocessedArgs){
  List<String> args=new LinkedList<>();
  Collections.addAll(args,unprocessedArgs);
  args.remove(0);
  Pattern argPattern=Pattern.compile("(--[a-zA-Z_]+)=(.*)");
  Pattern quotesPattern=Pattern.compile("^['\"](.*)['\"]$");
  List<String> processedArgs=new ArrayList<>(args.size());
  for (  String arg : args) {
    Matcher matcher=argPattern.matcher(arg);
    if (matcher.matches()) {
      processedArgs.add(matcher.group(1));
      String value=matcher.group(2);
      Matcher quotesMatcher=quotesPattern.matcher(value);
      if (quotesMatcher.matches()) {
        processedArgs.add(quotesMatcher.group(1));
      }
 else {
        processedArgs.add(value);
      }
    }
 else {
      processedArgs.add(arg);
    }
  }
  return processedArgs.toArray(new String[args.size()]);
}

private static String [ ] preProcessArgs ( String [ ] unprocessedArgs ) { List < String > args = new LinkedList < > ( ) ; Collections . addAll ( args , unprocessedArgs ) ; args . remove ( 0 ) ; Pattern argPattern = Pattern . compile ( "(--[a-zA-Z_]+)=(.*)" ) ; Pattern quotesPattern = Pattern . compile ( "^['\"](.*)['\"]$" ) ; List < String > processedArgs = new ArrayList < > ( args . size ( ) ) ; for ( String arg : args ) { Matcher matcher = argPattern . matcher ( arg ) ; if ( matcher . matches ( ) ) { processedArgs . add ( matcher . group ( 1 ) ) ; String value = matcher . group ( 2 ) ; Matcher quotesMatcher = quotesPattern . matcher ( value ) ; if ( quotesMatcher . matches ( ) ) { processedArgs . add ( quotesMatcher . group ( 1 ) ) ; } else { processedArgs . add ( value ) ; } } else { processedArgs . add ( arg ) ; } } return processedArgs . toArray ( new String [ args . size ( ) ] ) ; }
preprocesses command line arguments to make them conform to args4j assumptions ( for backwards compability ) and strip off the directive .
