import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?=.*\\{myVariable1\\})(?=.*<html>)(?!.*<script>)";
final String string = "Recycle Bin <scrippt>\n"
+ "Assigned to me 18 work items (1 selected)\n"
+ "ResultsEditorCharts Work item paneBottom\n"
+ "Save query\n"
+ "Column options {myVariable1}\n"
+ "Filter\n"
+ "IDWork Item TypeTitleStateRemaining WorkSeverityCreated Date705801Bug Ipad Tablet_PM Planning Labor Grid: Show Cost/Billing dropdown menu is overlapped by Plan Settings menu in PM workspace >> Planning Labor gridCommitted 38/24/2016 11:49:02 PM705969Bug Android Tablet_PM Planning Labor Grid: Columns displayed in Labor middle grid are overlappingCommitted 38/25/2016 4:56:55 AM705973Bug Android Tablet_PM Planning Labor Grid: Available Columns and Selected Columns grids are not displayed in Labor Grid SettingsCommitted 38/25/2016 5:08:06 AM712031Bug Column settings do not use the correct defaultsCommitted 39/14/2016 12:22:09 PM716142Bug Ipad Tablet_PM Plan/Project mode: List of Projects are not displayed properly in Project Result list dropdown menuCommitted 39/28/2016 2:06:17 AM707226Task Dev: Client - Remove Project Settings option and move individual settings to other placesDone 8/30/2016 4<html>35:35 PM619943Task Dev: Client - Actions popup menuDone 7/1/2016 2:03:11 PM693953Task dev:fix options above grid (PBI 612771)Done 7/26/2016 1:36:11 PM696198Task Dev: Changes to grid column selection dialog to support cost and billing views.Done 8/1/2016 1:37:43 PM699509Bug # selections above grid doesnt appear when paging is appliedIn Development 38/9/2016 12:46:11 PM699660Bug # selection doesn't show when \"select All\" checkbox is disabledIn Development ";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
final Matcher matcher = pattern.matcher(string);
if (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