import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\/.*\\.[\\w:]+";
final String string = "In file included from /some/directoy/3.33A.37.2/something else/dogs.txt,\n"
+ " from /some/directoy/something else/dogs.txt,\n"
+ " from /some/directoyr/3.33A.37.2/something else/dogs.txt,\n"
+ " from /var/log/xyz/10032008.log,\n"
+ " from /var/log/xyz/test.c:29:\n"
+ "Solution:\n"
+ "please the file something.h has to be alone without others include, it has to be present in release letter, \n"
+ "in order to be included in /var/log/xyz/test.c automatically\n"
+ "Other Note: \n"
+ "The file something.c must contain the somethinge.h and not the ecpfmbsd.h because it doesn't contain C operative code.. everything good.. \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