import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = ",\\{\"author[^*]*],\\s*";
final String string = "json_file<- '{\"_id\":{\"$oid\":\"4f27779008d69a6dba0208f6\"},\"actor\":{\"gravatar_id\":\"92e5c51218f00220e0362c47b2a94b9a\",\"id\":NumberInt(228889),\"login\":\"stefankendall\",\"url\":\"https://api.github.com/users/stefankendall\"},\"created_at\":\"2012-01-31T05:09:37Z\",\"id\":\"1515677813\",\"org\":{\"url\":\"https://api.github.com/orgs/\"},\"payload\":{\"commits\":[{\"author\":{\"email\":\"skendall@skendalllaptop.(none)\",\"name\":\"skendall\"},\"message\":\"Made test packages mimic app layout.\",\"sha\":\"faf1b478f4d98202d4169b6d310812b14ad7f676\",\"url\":\"https://api.github.com/repos/stefankendall/wendler531-webservices/commits/faf1b478f4d98202d4169b6d310812b14ad7f676\"},{\"author\":{\"email\":\"skendall@skendalllaptop.(none)\",\"name\":\"skendall\"},\"message\":\"_id is now pulled out of \\\"get\\\" responses\",\"sha\":\"d2087821e865ebebf9ff6e47cffb41dd16c6c871\",\"url\":\"https://api.github.com/repos/stefankendall/wendler531-webservices/commits/d2087821e865ebebf9ff6e47cffb41dd16c6c871\"}],\"head\":\"d2087821e865ebebf9ff6e47cffb41dd16c6c871\",\"push_id\":NumberInt(59920001),\"ref\":\"refs/heads/master\",\"size\":NumberInt(2)},\"public\":true,\"repo\":{\"id\":NumberInt(3186494),\"name\":\"stefankendall/wendler531-webservices\",\"url\":\"https://api.github.com/repos/stefankendall/wendler531-webservices\"},\"type\":\"PushEvent\"}'\n";
final String subst = "";
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