6 Replies Latest reply: Apr 5, 2011 3:52 AM by EJP RSS

    Match string and retrieve part of string from match

    852632
      Hi,

      I'm trying to parse a html-page to retrieve a certain value.
      The string should match some pattern. Then I want to retrieve a part of the string from the match. In my example case: XXX.
      String string2Match = "    <input type=\"text\" name=\"match\" value=\"XXX\"       ";
      String regex = ".*<input type=\"text\" name=\"match\" value=\"\\w*\".*";
      Pattern pattern = Pattern.compile(regex);
      Matcher matcher = pattern.matcher(string2Match);
      if (matcher.matches()) {
         // in this case I want to retrieve a part of the string from the match. here: XXX.
      }
      Can this be done, without parsing the matcher.group()-findings again.

      Thanks
      Jonny