Extract Substrings using regex Java [closed]

This regex will match all the data that are you asking:


Where \(DT\s\w+ match the Determiner, thr white space and the string, .{3} match ) ( and NN\s\w+\) match the Noun, singular or mass.
Using regexpal match the data but if you want use it in Java code you need to escape the charactes so it will look like this:

Pattern p = Pattern.compile("\\(DT\\s\\w+.{3}NN\\s\\w+\\)");

Leave a Comment