import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<IdentityField\\b[^>]*path=\\\"name\\\"[^>]+?\\/>";
final String string = "<>\n"
+ " <form onSubmit={handleSubmit(onSave)} className=\"max-w-3xl\" noValidate>\n"
+ " <IdentityField\n"
+ " control={control}\n"
+ " name=\"Name\"\n"
+ " type=\"text\"\n"
+ " path=\"name\"\n"
+ " className=\"mt-8 mb-16\"\n"
+ " />\n\n"
+ " <IdentityField\n"
+ " control={control}\n"
+ " name=\"Projection Link\"\n"
+ " type=\"text\"\n"
+ " path=\"link\"\n"
+ " className=\"mt-8 mb-16\"\n"
+ " startAdornment={\n"
+ " <InputAdornment position=\"start\">\n"
+ " https://{subdomain_user}.thebluelobby.com/best-dressed/\n"
+ " </InputAdornment>\n"
+ " }\n"
+ " endAdornment={\n"
+ " <InputAdornment position=\"end\">\n"
+ " <IconButton onClick={openProjectionPage}>\n"
+ " <FuseSvgIcon>heroicons-outline:external-link</FuseSvgIcon>\n"
+ " </IconButton>\n"
+ " </InputAdornment>\n"
+ " }\n"
+ " />\n"
+ " <IdentityField\n"
+ " control={control}\n"
+ " name=\"Sexualisation\"\n"
+ " type=\"boolean\"\n"
+ " className=\"mt-8 mb-16\"\n"
+ " path=\"sexualisation\"\n"
+ " />\n"
+ " <IdentityField\n"
+ " control={control}\n"
+ " name=\"Active\"\n"
+ " type=\"boolean\"\n"
+ " className=\"mt-8 mb-16\"\n"
+ " path=\"active\"\n"
+ " />\n"
+ " <LoadingButton variant=\"contained\" type=\"submit\" disabled={!isEdited}>\n"
+ " Save\n"
+ " </LoadingButton>\n"
+ " </form>\n"
+ "<p>abc</p>\n"
+ " </>";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
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