import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "_(.*?)(?=\\\\)";
final String string = "{\\\"header\\\":[[{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Opportunity<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Date<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Launch Vehicle<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Excess Capacity<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Orbit<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"text\\\",\\\"text\\\":\\\"<p>Cost<\\\\/p>\\\",\\\"type\\\":\\\"Paragraph\\\"}]}]],\\\"style\\\":\\\"normal\\\",\\\"body\\\":[[{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"name\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380313181_755886_144674\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380432770_58741_154478\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380396246_873072_144853\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380432768_736282_154472\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380395593_804641_144677\\\",\\\"type\\\":\\\"Paragraph\\\"}]},{\\\"colspan\\\":\\\"1\\\",\\\"rowspan\\\":\\\"1\\\",\\\"content\\\":[{\\\"sourceType\\\":\\\"reference\\\",\\\"sourceProperty\\\":\\\"value\\\",\\\"source\\\":\\\"_18_0_2_f280366_1447380433550_448862_154654\\\",\\\"type\\\":\\\"Paragraph\\\"}]}]],\\\"title\\\":\\\"Possible Rideshares\\\",\\\"type\\\":\\\"Table\\\"}\n\n"
+ "IShouldGet3Match,allTheSequenceBetweenaUnderScoreAndASlashHere'sOne:_1234_1234\\andheresAnother_1234_1234_1234\\OhLookAnotherOne!_123_12_1234567\\bahbahba\n";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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