I have a string like these "Marko's place" "boulevard "Arequipa"" strings that containing single or double quotes, in Java using regular expressions how get that the previous strings get like this "Marko\s place" "boulevard \"Arequipa\"" I am no have experience with regex, thank for any answer
OK, I am reading records from a mysql table and constructing the insert sql to pass this information to a sqlite table
Statement qryMySQL= cnMySql.createStatement();
ResultSet rs = qryMySQL.executeQuery("select * from tblclientes ");
Statement qrySQLite = cnSqLite.createStatement();
qrySQLite.addBatch("begin transaction");
qrySQLite.addBatch("CREATE TABLE 'tblclientes' ('_id' INTEGER,'Nombres' varchar(25) DEFAULT NULL,'Apellidos' varchar(25) DEFAULT NULL,'RazSocial' varchar(20) DEFAULT NULL,'Direccion' varchar(50) DEFAULT NULL,'Ciudad' varchar(15) DEFAULT 'Arequipa','Fono' varchar(12) DEFAULT NULL,'Fax' varchar(12) DEFAULT NULL,'Email' varchar(35) DEFAULT NULL,'Ruc' varchar(12) DEFAULT NULL,'latitud' decimal(20,14) DEFAULT NULL,'longitud' decimal(20,14) DEFAULT NULL,'ruta' varchar(10) DEFAULT NULL,'sincro' CHAR(10),'copiar' BOOL DEFAULT 1)");
while (rs.next())
{
//System.out.println (rs.getInt(1) + " " + rs.getString (2) );
sql = "INSERT INTO tblclientes(_id,nombres,apellidos) " +
"VALUES("+rs.getInt("id")+", \""+rs.getString("nombres")+"\",\""+rs.getString("apellidos")+"\")";
qrySQLite.addBatch(sql);
// System.out.println (sql);
}
qrySQLite.addBatch("end transaction");
qrySQLite.executeBatch();
but some fields in the mysql table have the characters " and ' that causes error in sql insert sentence then I Need this
<Marko's place> ===> <Marko\'s place>
<boulevard "Arequipa"> ====> <boulevard \"Arequipa">
so the result must be add the \ before the " or '