I had been following the thread How to split a string in Java and had been successful.
But in the current usecase the String I am dealing with contains the special characters.
I am having a String as https://{domain name}/{type of data}/4583236-{name-of-perpetrators} and I want to extract 4583236 out of it.
The QA How to split the string using '^' this special character in java? is more or less related to the Question I already have mentioned previously but doesn't helps in my usecase.
My program is throwing PatternSyntaxException: Illegal repetition randomly on either of the special characters.
Code Block :
    String current_url = "https://{domain name}/{type of data}/4583236-{name-of-perpetrators}";
    String[] urlParts = current_url.split("type of data}/");
    String mySuburl = urlParts[1];
    String[] suburl = mySuburl.split("-{name-of-perpetrators");
    String mytext = suburl[0];
    System.out.println(mytext);
Error Stack Trace :
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition
{name-of-perpetrators
    at java.util.regex.Pattern.error(Unknown Source)
    at java.util.regex.Pattern.closure(Unknown Source)
    at java.util.regex.Pattern.sequence(Unknown Source)
    at java.util.regex.Pattern.expr(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.util.regex.Pattern.<init>(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.lang.String.split(Unknown Source)
    at java.lang.String.split(Unknown Source)
    at demo.TextSplit.main(TextSplit.java:18)
 
     
     
    