import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(insert\\s+into\\s+casi_tassazione\\s+)(\\(.+?\\))(\\s+values\\s+)(\\(.+?\\))(;)";
final String string = "INSERT INTO CASI_TASSAZIONE (ID_CSTASS, ID_DCHFIS, ESERCIZIO, PROGRESSIVO, ID_PARENT_CSTASS, NO_REINTIMAZIONE, ID_PERGIU, ID_STORGN, TASSAZIONE_UFFICIO, ID_OWNER, ID_WORKER, ID_UNTORG, PRIMO_GIORNO_ESECZ, ULTIMO_GIORNO_ESECZ, DATA_CAMBIO_STORGN, DATA_INS, INS_USERID, DATA_UPD, UPD_USERID) VALUES (100001, 100000, 2009, 0, NULL, 0, 100001, 2, 0, 10000, 10000, @idUnitaOrganizzativa, '2009-01-01', '2009-12-31', '2009-04-24', '2009-04-24 10:09:07.115', 'JUNIT', '2009-04-24 10:09:09.894', 'JUNIT');\n\n"
+ " INSERT INTO CASI_TASSAZIONE\n"
+ " (ID_CSTASS, ID_DCHFIS, ESERCIZIO, PROGRESSIVO, ID_PARENT_CSTASS, NO_REINTIMAZIONE, ID_PERGIU, ID_STORGN, TASSAZIONE_UFFICIO, ID_OWNER, ID_WORKER, ID_UNTORG, PRIMO_GIORNO_ESECZ, ULTIMO_GIORNO_ESECZ, DATA_CAMBIO_STORGN, DATA_INS, INS_USERID, DATA_UPD, UPD_USERID) VALUES (100001, 100000, 2009, 0, NULL, 0, 100001, 2, 0, 10000, 10000, @idUnitaOrganizzativa, '2009-01-01', '2009-12-31', '2009-04-24', '2009-04-24 10:09:07.115', 'JUNIT', '2009-04-24 10:09:09.894', 'JUNIT'),(ID_CSTASS, ID_DCHFIS, ESERCIZIO, PROGRESSIVO, ID_PARENT_CSTASS, NO_REINTIMAZIONE, ID_PERGIU, ID_STORGN, TASSAZIONE_UFFICIO, ID_OWNER, ID_WORKER, ID_UNTORG, PRIMO_GIORNO_ESECZ, ULTIMO_GIORNO_ESECZ, DATA_CAMBIO_STORGN, DATA_INS, INS_USERID, DATA_UPD, UPD_USERID) VALUES (100001, 100000, 2009, 0, NULL, 0, 100001, 2, 0, 10000, 10000, @idUnitaOrganizzativa, '2009-01-01', '2009-12-31', '2009-04-24', '2009-04-24 10:09:07.115', 'JUNIT', '2009-04-24 10:09:09.894', 'JUNIT');\n";
final String subst = "$1$2$3$4$5";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html