I am using Java and have a String, sum, whose content will be something like this:
A bunch of miscellaneous text
A bunch more miscellaneous text
Handicap Accessible *value*
More miscellaneous Text
Even more miscellaneous text
value can be Yes, No or None
I am trying to get the value of value with a regular expression. I can't just do a sum.replaceAll("^.*Handicap Accessible ","")
because there are new lines and other characters which don't count in "."
.
I am trying to use a regular expression but I can't get it right. Below is what I have tried, both with and without the backslashes. And notice that this is from java so I need to use two backslashes (\\):
Pattern pat = Pattern.compile("Handicap Accessible \\([A-Za-z]*\\)");
Matcher match = pat.matcher(sum);
String newAccess = null;
while (match.matches()) {
newAccess = match.group(1);
break;
}
But when I print the value of newAccess it is always null. If I initialize newAccess to something else like "GLUB" then "GLUB" is what is printed at the end, meaning the matches loop is not being entered.
Any suggestions for the correct pattern to use?