import gnu.regexp.*;

class Test {

   public static void main(String[] argv) throws REException {
      // Construct the regular expression to extract function keys description
      RE     expr = new RE("F(\\d+)[=: ]+(([\\w']+(\\s[^F ]+)*)+)");
      // Construct the keyboard description found in the screen
      String str = "         F3 to Return to the Menu         F9 to delete the customer account      ";

      // Purpose of this loop is to process each function key describe in the line
      // It works with gnu-regexp-1.0.8 but throws an OutOfMemoryError with gnu-regexp-1.1.4
      for (REMatchEnumeration enum = expr.getMatchEnumeration(str); enum.hasMoreMatches();) {
         REMatch match = (REMatch) enum.nextMatch();
         System.out.println("Match=" + match);
      }
   }
}