java字符串搜索

java字符串搜索,java,string,Java,String,很抱歉问了一个很蹩脚的问题,我刚刚发现我不熟悉字符串操作,我所拥有的是一个字符串 http://oauth.vk.com/blank.html#access_token= 533bacf01e11f55b536a565b57531ad114461ae8736d6506a3&expires_in=86400&user_id=8492 我需要的是3个字符串: access token="533bacf01e11f55b536a565b57531ad114461ae8736d65

很抱歉问了一个很蹩脚的问题,我刚刚发现我不熟悉字符串操作,我所拥有的是一个字符串

http://oauth.vk.com/blank.html#access_token= 533bacf01e11f55b536a565b57531ad114461ae8736d6506a3&expires_in=86400&user_id=8492 
我需要的是3个字符串:

 access token="533bacf01e11f55b536a565b57531ad114461ae8736d6506a3"
 expiration="86400"
  user_id="8492"

如何将给定字符串划分为所需的3个字符串?谢谢

请使用正则表达式尝试此代码段:

String url = "http://oauth.vk.com/blank.html#access_token=533bacf01e11f55b536a565b57531ad114461ae8736d6506a3&expires_in=86400&user_id=8492";

Pattern pattern = Pattern.compile(".+access_token=(.+)&expires_in=(.+)&user_id=(.+)");
Matcher matcher = pattern.matcher(url);

if (matcher.matches()) {
    System.out.println("access_token=" + matcher.group(0));
    System.out.println("expires_in=" + matcher.group(1));
    System.out.println("user_id=" + matcher.group(2));
}
这三个匹配结果分别位于matcher对象的0组、1组和2组。

希望这有助于:

String str=”http://oauth.vk.com/blank.html#access_toke...“

str=str.substring(str.indexOf(“#”)+1)

str.split(&)

干杯