I am simply trying to capture a string surrounded static text. I'll illustrate by example. Here is the string I'm working with ...
String idInfo = "Any text up here\n" +
"Here is the id\n" +
"\n" +
"?a0 12 b5\n" +
"&Edit Properties...\n" +
"And any text down here";
Or in pretty print ...
Any text up here
Here is the id
?a0 12 b5
&Edit Properties...
And any text down here
And I'm using the following code to try and print the ID number ...
Pattern p = Pattern.compile("Here is the id\n\n\?[a-z0-9]{2}( [a-z0-9]{2}){2}\n&Edit Properties...);
Matcher m = p.matcher(idInfo);
String idNum = m.group(1);
System.out.println(idNum);
And I want to simply output the ID number, so the output I desire for this example is ...
a0 12 b5
However, I'm getting a "No match found" exception when I run my code. What am I doing wrong? Is there a simpler, more elegant way to accomplish my solution?