Hi friends,
I was trying out one regular expression in java but, for some reasons its not working. The test string looks something like this in the eclipse watch window:-
Test string:-*
Content-Disposition: form-data; name="name"\n\nOmkar\n|
In the above test string the last character is a pipe symbol.
And the java code i have written is: -
code:
public static void getParameterValue(String paramName, String testParameter) {
String parameterRegex = "name=\""+paramName+"\"(.*)|";
Pattern pattern = Pattern.compile(parameterRegex,Pattern.DOTALL);
Matcher matcher = pattern.matcher(testParameter);
boolean isFound = matcher.find();
if (isFound) {
System.out.println("The parameter value is : "+matcher.group(1));
}
}
After, the debug line moves over the first line in this method, the value contained in the "parameterRegex" string variable is:-
Regex:-*
name="name"(.*)|
However, my SOP statement, prints null....even though, "isFound" variable is true....can someone please explain me what could be the problem, where i am going wrong ?....
I have even, set the DOTALL option for the regex.
please some one help me!
Thanks and Regards
Omkar Patkar