I'm currently studying informatics and know what a regex is (not in java so). I have an input like :
"String1 ( Nr = 323) String2 String3 (Nr = 3)"
I wanted to split it by using:
split("[ ()=]");
because I think this would split all " ","(",")","=". Am i right? or do I need to put a + behind it? and if this is already right I could add a * so I can also split for something like "(("?
If this isn't the problem then my other question regarding regex in java is how can I check if my String only contains numbers.
I tried:
contains(".*\\d+.*")
matches(".*\\d+.*")
But I'm pretty sure one of them is working. So my problem should be with the splitting regex.
My original problem is that I get a NumberFormatException for my splitted String array at the index 2 which normally should be "323"?
Can I use my regex with a *
? like "[ ()=]*"
?
Thanks in advance