Android-隐藏html输入字段的正则表达式模式';s值

Android-隐藏html输入字段的正则表达式模式';s值,android,html,regex,token,hidden,Android,Html,Regex,Token,Hidden,我对正则表达式模式非常不熟悉,但这正是我想要的: 我有一个html网页,在该网页的某个地方我有: 因此,我的问题是:如何在Android中获得隐藏文本字段的值(我想要的值) 我已经做了HttpGet(参见下面的代码),我只需要知道正确的模式 代码: 这确实让我得到了隐藏字段的标记,但现在我有了一个全新的问题。。令牌已更改,因为Jsoup将打开一个新会话。所以基本上我不能使用Jsoup,而是“被迫”使用已经打开的DefaultHttpClient,这也是我在文章中使用的 不过,我会为此提出一个新问

我对
正则表达式模式非常不熟悉,但这正是我想要的:

我有一个html网页,在该网页的某个地方我有:

因此,我的问题是:如何在Android中获得
隐藏文本字段的值(我想要的值)

我已经做了
HttpGet
(参见下面的代码),我只需要知道正确的
模式

代码:

这确实让我得到了隐藏字段的标记,但现在我有了一个全新的问题。。令牌已更改,因为Jsoup将打开一个新会话。所以基本上我不能使用Jsoup,而是“被迫”使用已经打开的DefaultHttpClient,这也是我在文章中使用的

不过,我会为此提出一个新问题,因为我最初的回答只是我自己的错误提问(没有提供所有细节),所以我接受非法论点的答案为正确答案(虽然它没有解决我当前的问题,但可能会帮助其他人)。

尝试使用库。它是为此目的而构建的正则表达式解析器

// Method to get the hidden-input value of the Token
private String getToken(){
    String url = "http://myhost/Account/Login";
    String hidden_token = "";
    String response = "";

    HttpGet get = new HttpGet(url);
    try{
        // Send the GET-request
        HttpResponse execute = MainActivity.HttpClient.execute(get);

        // Get the response of the GET-request
        InputStream content = execute.getEntity().getContent();
        BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
        String s = "";
        while((s = buffer.readLine()) != null)
            response += s;
    }
    catch(Exception ex){
        ex.printStackTrace();
    }

    // Get the value of the hidden input-field with the name __RequestVerificationToken
    Pattern pattern = Pattern.compile("<input name=\"" + TOKEN + "\" type=\"hidden\" value=\".\" />", Pattern.DOTALL);
    Matcher matcher = pattern.matcher(response);
    while(matcher.find())
        hidden_token = matcher.group();

    return hidden_token;
}
// Get the value of the hidden input-field with the name __RequestVerificationToken
Document doc = Jsoup.connect(url).get();
org.jsoup.nodes.Element el = doc.select("input[name*=" + TOKEN).first();
hidden_token = el.attr("value");