如何从字符串中提取 HTML 完整的 link?

How to extract an HTML full link from a string?

我正在尝试从字符串中提取 Html link。我尝试使用模式和匹配器来查找 link 但我的正则表达式是错误的。我只想获取 cloneurlHttp :任何解决此问题的帮助?

并且这个字符串不在JSon。

     String s = "{RepositoryMetadata: {AccountId: 329791006272,RepositoryId: 425f5fc5-18d8-4ae5-b1a8-55eb9cf72bef,RepositoryName: CodeCommitTest,DefaultBranch: master,LastModifiedDate: Tue Oct 20 13:50:57 ACDT 2015,CreationDate: Tue Oct 13 16:36:03 ACDT 2015,CloneUrlHttp: https://git-codecommit.us-east-1.amazonaws.com/v1/repos/CodeCommitTest,CloneUrlSsh: ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/CodeCommitTest,Arn: arn:aws:codecommit:us-east-1:329791006272:CodeCommitTest}}";

    String pattern = "^\CloneURLHttp:\s(.*?)$";
    String httpaddress = "";

    Pattern r = Pattern.compile(pattern);
    Matcher m;



        m = r.matcher(s);
        if (m.find()) {
            httpaddress = m.group(1);

        }


    System.out.println(httpaddress);

使用字边界和否定字符class。

String pattern = "(?i)\bCloneURLHttp:\s*([^,]*)";
Pattern r = Pattern.compile(pattern);
Matcher m;
m = r.matcher(s);
String httpaddress = "";
if (m.find()) {
        httpaddress = m.group(1);
 }

DEMO