Answer the question
In order to leave comments, you need to log in
Regular expression question with "any character except" condition in Java?
Why is the regular expression not working as intended?
Source string:
String source = "-1 - -2233 -3- -4";
Regular expression:
String NUMBER_INT_SEPARATOR = "[^-(?=\\d)]";
Splitting a string by regular expression will be done using the split() method of the String object .
For reference
The split() method splits the string around matches with the given regular expression.
-1
-
-2233
-3-
-4
Answer the question
In order to leave comments, you need to log in
x(?=y) - Matches 'x' only if 'x' is followed by 'y'. It's called preemption (source).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question