I have the following Java code that is supposed to extract a url from a String object
public static void main() {
String text = "Link to https://some.domain.com/subfolder?sometext is available";
String regex = "https://some\\.domain\\.com/subfolder[^ ]*";
Pattern urlPattern = Pattern.compile(regex);
Matcher m = urlPattern.matcher(text);
String url = m.group();
System.out.println(url);
return;
}
However, there is no match and the code fails with IllegalStateException
.
What is wrong with the RegEx?