Answer the question
In order to leave comments, you need to log in
What should I fix in the regex so that it separates signed numbers?
There is a line like this:
5+1/2*(2+5*2- 14))*1200
I made up a regular expression:
(?<=\D)(?=\d|\D)|(?<=\d|\D)(?=\D)
It splits the given string into numbers, brackets and arithmetic operators. As a result, we get:
Найдено математическое выражение: [(-5+1/2*(2+5*2- --j))*1200]
Символ: [(]
Символ: [5]
Символ: [+]
Символ: [1]
Символ: [/]
Символ: [2]
Символ: [*]
Символ: [(]
Символ: [2]
Символ: [+]
Символ: [5]
Символ: [*]
Символ: [2]
Символ: [-]
Символ: [14]
Символ: [)]
Символ: [)]
Символ: [*]
Символ: [1200]
Символ: [(]
Символ: [-5] <- СМОТРИ СЮДА, ТУТ ЧИСЛО СО ЗНАКОМ, НЕЛЬЗЯ ОТДЕЛЯТЬ ЗНАК ОТ ЧИСЛА
Символ: [+]
Символ: [1]
Символ: [/]
Символ: [2]
Символ: [*]
Символ: [(]
Символ: [2]
Символ: [+]
Символ: [5]
Символ: [*]
Символ: [2]
Символ: [-]
Символ: [14]
Символ: [)]
Символ: [)]
Символ: [*]
Символ: [1200]
Answer the question
In order to leave comments, you need to log in
Try to look at the area of such a regular season:
(-?\d*\.{0,1}\d+)
She will choose any numbers. positive and negative
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question