I created this regex, but somehow it only detects the first part of the regex not the last part. I would like to know what is going on?
Here's the code:
String m = -2√3254i/18.5
String regex = "-?\\d+(\\.\\d*)?\\√\\d+(\\.\\d*)?i\\/\\d+(\\.\\d*)?"
I have tried many different ways, such as:
-?\\d+(\\.\\d*)?\\√\\d+(\\.\\d*)?i+\\/+\\d+(\\.\\d*)?
-?\\d+(\\.\\d*)?\\√\\d+(\\.\\d*)?i/\\d+(\\.\\d*)?
-?\\d+(\\.\\d*)?\\√\\d+(\\.\\d*)?i\\(\\/\\d+(\\.\\d*))?
none of them work.
the output is always
-2√3254
Any suggestions,
thank you
but somehow it only detects the first part of the regex not the last part?String m = "-2√3254i/18.5"; String regex = "-?\\d+(\\.\\d*)?\\√\\d+(\\.\\d*)?i+\\/+\\d+(\\.\\d*)?"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(m); if (matcher.find()) { System.out.println(matcher.group()); }?