Java:如何提取信息;rel=";“自我”&引用;用正则表达式

Java:如何提取信息;rel=";“自我”&引用;用正则表达式,java,regex,Java,Regex,我想提取此字符串中关联的所有URL和“rel”信息: <https://api-staging.xxx.com/v1/users>; rel="self", <https://api-staging.xxx.com/v1/users?page=1,0>; rel="next" ;rel=“self”;rel=“下一步” 所以我从以下几点开始: Pattern mentionPattern = Pattern.compile("<(.+?)>"); Matc

我想提取此字符串中关联的所有URL和“rel”信息:

<https://api-staging.xxx.com/v1/users>; rel="self", <https://api-staging.xxx.com/v1/users?page=1,0>; rel="next"
;rel=“self”;rel=“下一步”
所以我从以下几点开始:

Pattern mentionPattern = Pattern.compile("<(.+?)>");
Matcher mentionMatcher = mentionPattern.matcher(url);
Pattern=Pattern.compile(“”);
Matcher-SindeMatcher=sindePattern.Matcher(url);
它非常适合URL,但我不知道如何提取“rel”信息。在这个例子中,我想提取“self”和“next”


非常感谢各位

你们可以这样做:

String test = "<https://api-staging.xxx.com/v1/users>; rel=\"self\", <https://api-staging.xxx.com/v1/users?page=1,0>; rel=\"next\"";
Pattern mentionPattern = Pattern.compile("[<\"](?<content>.+?)[>\"]");
Matcher m = mentionPattern.matcher(test);
while(m.find()) {
    System.out.println(m.group("content")); // using named groups
}

不是你的投票人,但是如果你正在解析HTML,为什么不使用一个专用的HTML解析器呢?或者,如果是XML,也是一样的:为什么不使用专用的XML解析器呢?您看到的可能的重复?
https://api-staging.xxx.com/v1/users
self
https://api-staging.xxx.com/v1/users?page=1,0
next