I'm trying to split a string at every "." or "?" and I use this regular expression:
(?<=(?!.[0-9])[?.])
In theory the code also prevents splitting if the point is followed by a number so things like 3.000 are not split and it also includes the point in the new string.
For example if I have this text: "Hello. What's your favourite number? It's 3.560." I want to get thi: "Hello.","What's your favourite number?","It's 3.560."
I've made a simple java program on my computer and it works exactly like I want:
String[] x = c.split("(?<=(?!.[0-9])[?.])");
for(String v : x){
System.out.println(v);
}
However when I use this same regex in my Android app it doesn't split anything...
x = txt.split("(?<=(?!.[0-9])[?.])");
//This, in my android app, returns an array with only one entry which is the whole string without splitting.
PS. Using (?<=[?.]) works so the problem must be in the (?!.[0-9]) part which is meant to exclude points followed by a number.