I obtain a response by HttpGet. After getEntity().getContent() I get the code of HTML page, and then convert this page to String pageHTML.
I need to use regular expression match the pageHTML and then obtain the result.
I have created the regular expression.
If regular expression just return a value, how to create? If regular expression just return n values, how to create?
You can use groups to receive multiple values from a regular expression. See this for details.
Pattern datePatt = Pattern.compile("([0-9]{2})/([0-9]{2})/([0-9]{4})");
Matcher m = datePatt.matcher(dateStr);
if (m.matches()) {
int day = Integer.parseInt(m.group(1)); // get values inside the first (..)
int month = Integer.parseInt(m.group(2)); // get values inside the second (..)
int year = Integer.parseInt(m.group(3)); // get values inside the third (..)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.