delimiterRegex = escapeCharsToRegex(stringMap, pattern, delimiter);
throw new UnimplementedException("pg_copy_from with non-default delimiter");
  public static boolean pg_copy_from(Env env,                                     @NotNull Postgres conn,                                     String tableName,                                     ArrayValue rows,                                     @Optional("") String delimiter,                                     @Optional("") String nullAs)  {    try {      // The character that makes the special char: '\u0009' .. '\u001F'      String stringMap[] = new String[] {"t",  // u0009 (horizontal tab)                                         "n",  // u000A (new line)                                         "v",  // u000B (vertical tab)                                         "f",  // u000C (form feed)                                         "r",  // u000D (carriage return)                                         "\u000E-\u001B",          //@todo                                         "\u001Cfileseparator",    //@todo                                         "\u001Dgroupseparator",   //@todo                                         "\u001Erecordseparator",  //@todo                                         "\u001Funitseparator"};   //@todo      Pattern pattern = Pattern.compile("(\\p{Cntrl}|\\\\|\\.|\\-|\\*|\\+|\\?|\\]|\\[|\\^|\\{|\\}|\\(|\\)|\\|)");      String delimiterRegex;      if (delimiter.equals("")) {        delimiter = "\t";        delimiterRegex = "\\t";      } else {        delimiterRegex = escapeCharsToRegex(stringMap, pattern, delimiter);      }      String nullAsRegex;      if (nullAs.equals("")) {        nullAs = "\n";        nullAsRegex = "\\n";      } else {        nullAsRegex = escapeCharsToRegex(stringMap, pattern, nullAs);      }      ArrayValueImpl newArray = (ArrayValueImpl) rows;      int nasize = newArray.size();      for (int i=0; i<nasize; i++) {        String values = newArray.get(LongValue.create(i)).toString();        // For testing only:        // String values = "\n\tNUMBER1stcolumn\t\n\t\n\tNUMBER2ndcolumn\tNUMBER3rdcolumn\tNUMBER4thcolumn\t\n";        values = "'"+values.replaceAll(delimiterRegex, "','")+"'";        values = values.replaceAll(",'"+nullAsRegex+"',", ",NULL,");        // We need to call it twice because the replaceAll(regexp) would not        // replace adjacent ",'\\n'," matches.        values = values.replaceAll(",'"+nullAsRegex+"',", ",NULL,");        values = values.replaceAll("^'"+nullAsRegex+"',", "NULL,");        values = values.replaceAll(",'"+nullAsRegex+"'$", ",NULL");        String query = "INSERT INTO "+tableName+" VALUES("+values+")";        pg_query(env, conn, query);      }      return true;    } catch (Exception ex) {      log.log(Level.FINE, ex.toString(), ex);      return false;    }  }