import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<code>[^<]*</code>";
final String string = "<p>I am trying to have the \\\"Birthday\\\" and \\\"Name\\\" properties of an Org-mode entry added to the agenda automatically:</p>\\n\\n<pre><code>* John\\n :PROPERTIES:\\n :Name: John\\n :Birthday: (5 4 1900)\\n :END:\\n</code></pre>\\n\\n<p>I found a way to add an entry at the correct anniversary date in the agenda by inserting the following line right after the properties:</p>\\n\\n<pre><code>%%(apply 'diary-anniversary (read (org-entry-get nil \\\"Birthday\\\"))) John\\n</code></pre>\\n\\n<p>However, using this code, I still have to enter the name manually. Is there a way to have the value of the \\\"Name\\\" property added to the diary text automatically for all entries?</p>\\n\\n<p><strong>EDIT 1</strong>: the example did not work before, now added parantheses around the value of the birthday property</p>";
final Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE);
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