import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\s*?'(.*?)'\\s*?=>\\s*?(.*?),";
final String string = " 'id' => $place->{'places.id'},\n"
+ " 'status' => 0,\n"
+ " 'brondta' => $jdate->toSql(),\n"
+ " 'surname' => $place->{'places.surname'},\n"
+ " 'first_name' => $place->{'places.first_name'},\n"
+ " 'middle_name' => $place->{'places.middle_name'},\n"
+ " 'sex' => $place->{'places.sex'},\n"
+ " 'birth' => $place->{'places.birth'},\n"
+ " 'document_type' => $place->{'places.document_type'},\n"
+ " 'document_number' => $place->{'places.document_number'},\n"
+ " 'document_country' => $place->{'places.document_country'},\n"
+ " 'modified_by' => $juser->id,\n"
+ " 'modified_time' => $jdate->toSql(),\n";
final String subst = "$placesInOrder[$placesCount]->$1 = $2;\\n";
final Pattern pattern = Pattern.compile(regex, 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