From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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,254 Views)

Could you post your VI?

0 Kudos
Message 2 of 3
(10,208 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,192 Views)