I want to split the string by space, below code not working. I’m new to Java. Please share the good tutorials for beginners. String s1 = “Welcome to Hello World Java”; String[] str = s1.split(” “);
Discy Latest Questions
I’m getting below error while split the string by “\” even I used with escape “\\” but still getting the exception Exception in thread “main” java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ at java.base/java.util.regex.Pattern.error(Pattern.java:2029) at java.base/java.util.regex.Pattern.compile(Pattern.java:1790) at java.base/java.util.regex.Pattern.<init>(Pattern.java:1431) at java.base/java.util.regex.Pattern.compile(Pattern.java:1070)
I’m trying to replace all the question (?) mark in my document String s = “xyz?”; s.replaceAll(“?”.””); using sample code mentioned above but getter java.util.regex.PatternSyntaxException: Dangling meta character ‘?’ near index 0 what I’m doing wrong here ? why I’m getting this error ? java.util.regex.PatternSyntaxException: ...