Regex trying to get some text after text doesn’t work

I got this code which should retrieve the id value from the url.:

        String xmlTag = "";
        xmlTag = xmlTag.replaceAll("/", "//");

        //regex variables
        final String regexUrl = "(?:(?:http|https):////)?(?:www.)?*#!//)?(?:[?w-]*//)?(?:profile.asp?id=(?=d.*))?([w-]*)?";
        final Pattern patternUrl = Pattern.compile(regexUrl);
        final Matcher matcherUrl = patternUrl.matcher(xmlTag);  

        String urlResult =;         
        System.out.println("group(0) = " + urlResult);
        String regexId = "(?<=http:////*";
        System.out.println("regexId =   " + regexId);

        final Pattern patternId = Pattern.compile(regexId);
        final Matcher matcherId = patternId.matcher(urlResult);         
        System.out.println("id = " + matcherId.matches());

The output should be: 123456789 which is ‘true’ for ‘atcherId.matches()’

But instead of that i’m getting ‘false’ like that:

Exception in thread "main" java.lang.IllegalStateException: No match found
    at Source)
    at MainClass.main(

Do I miss something here ?

Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.