import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = ".*\\n.*\\n.*\": \"(.*)\"\\n.*";
final String string = " {\n"
+ " \"timestamp\": [3344, 3345.04],\n"
+ " \"text\": \" אבל הוא גם יעלה.\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3347.04, 3349.74],\n"
+ " \"text\": \" בזה, בא מיד ביטחון התשובה,\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3349.74, 3351.74],\n"
+ " \"text\": \" להתעלות האדם גם אחרי הירידות כולן,\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3351.74, 3353.24],\n"
+ " \"text\": \" שאפשר להן להמצא בחיים,\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3353.24, 3355.04],\n"
+ " \"text\": \" תשב אנוש עד דכא\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3355.04, 3356.4],\n"
+ " \"text\": \" ותאמר שובו בני אדם.\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3356.4, 3362.04],\n"
+ " \"text\": \" ברור, אמרת ואפשרת וברור שבסוף כל האדם וכל המציאות תשוב למקורה.\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3362.04, 3363.04],\n"
+ " \"text\": \" בסדר?\"\n"
+ " },\n"
+ " {\n"
+ " \"timestamp\": [3363.04, 3364.57],\n"
+ " \"text\": \" טוב.\"\n"
+ " }";
final String subst = "$1";
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