LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular expression with minus sign

Solved!
Go to solution

Hi,

I have a string for example: "*(-25)-7+3". I want to seperate all the numbers and math operators into 2 arrays. For the number, I use [-]?[.]?[0-9]+[.]?[0-9]* and it works fine. However, if I use [+-*/] as a second expression, the software will take all the operator signs include the one inside the parentheses (which I don't want). How can I get rid of the minus sign in front of a number inside parentheses? For example, in this case, I would like to get *-+ instead of *--+. Any help is hightly aprreciated.

0 Kudos
Message 1 of 3
(10,470 Views)

Could you post your VI?

0 Kudos
Message 2 of 3
(10,424 Views)
Solution
Accepted by topic author Doan_Ha

The following regex will match a minus sign that is not preceeded by an opening parenthesis or a plus sign. You need to use Match Regular Expression not Match Pattern (Match Pattern has limited regex capability).

 

(?<!\()-|\+

 

Ben64

Message 3 of 3
(10,408 Views)