import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^.*?(IDC\\w*)[\\s\\S]*?(?:$|(,\\n.*$))(\\n|$)";
final String string = " LTEXT \"Width\",IDC_WIDTH_TEXT,203,74,22,10\n"
+ " EDITTEXT IDC_WIDTH_IN,244,73,57,12,ES_AUTOHSCROLL | WS_GROUP\n"
+ " CONTROL \"Manually scale instances and paper\",IDC_RAD_PSCALE_KEYIN,\n"
+ " \"Button\",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,89,132,10\n"
+ " CONTROL \"Keep drawing instance scale 1.0\",IDC_RAD_PSCALE_AUTO,\n"
+ " \"Button\",BS_AUTORADIOBUTTON,15,104,123,10\n"
+ " CONTROL \"Keep drawing paper scale 1.0\",IDC_RAD_ISCALE_AUTO,\n"
+ " \"Button\",BS_AUTORADIOBUTTON,15,119,118,10";
final String subst = "$1\\n";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
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