I want to retrieve some values from a webpage using Pattern
& Matcher
<form name="loginForm" id="loginForm" method="post" onsubmit="ScrollUp(60);return validateLoginForm();"
enctype="multipart/form-data" action="/login.php">
<input type="hidden" name="Rpidci" value="">
<div class="last_box">
<div class="second_box_heading_panel">
<h1>Existing users -
<span> Login here</span>
</h1>
</div>
<div class="second_box_form_panel">
<div class="error-msg">
</div>
<div class="name_form_panel">
<div class="name">User Name
</div>
<div class="name_text_field">
<input name="sHZnGSgdzmIJoKWOCHmYez" type="text" class="existing_user round_four" id="sHZnGSgdzmIJoKWOCHmYez" maxlength="10" value=""/>
</div>
</div>
<div class="name_form_panel">
<div class="name">Password
</div>
<div class="name_text_field"><input name="AWrPDfe" type="password" class="existing_user round_four" id="AWrPDfe" maxlength = "20"
value=""/>
</div>
</div>
<div class="login_btn"><a href="javascript:void(0);" onclick="javascript:ScrollUp(70);return validateLoginForm();"><img src="images/login_btn.png" title="login here" /></a></div>
</div>
</div>
<div class="name_form_panel"></div>
</div>
</div>
</form>
I want to retrieve values of this two fields
<input name="sHZnGSgdzmIJoKWOCHmYez" type="text" class="existing_user round_four" id="sHZnGSgdzmIJoKWOCHmYez" maxlength="10" value=""/>
&
<input name="AWrPDfe" type="password" class="existing_user round_four" id="AWrPDfe" maxlength = "20" value=""/>
I tried several times but failed in getting the output. Please help.
EDIT:
The code I tried is as below: (not the same as I wrote initially as I was frustrated and messed it up very much)
Matcher matcher = Pattern.compile("<form name=\"loginForm\" .+ method=\"post\" .+ action=\"/login.php\">\\s*<input[^>]+>\\s*<input[^>]+>\\s*").matcher(loginResp);
String[] strArr = matcher.group(0).split("<input");
String str1 = "";
String str2 = "";
String str3 = "";
String str4 = "";
Pattern localPattern = Pattern.compile(" name=\"([^\\s]+)\" type=\"text\" id=\"([^\\s]+)\" value=\"([^\\s]+)\" />");
Matcher localMatcher2 = localPattern.matcher(strArr[3]);
if (localMatcher2.find()) {
str1 = localMatcher2.group(1);
echo("STR1 " + str1);
str2 = localMatcher2.group(3);
echo("STR2 " + str2);
}