LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use regular expression to replace strings delimited by numbers or letters

Hello,

I have a formula string like this:

 

mod1.b1+mod1.b11-mod2.b3

 

Using Search and Replace function (with regular expression), I'd like to replace substring "mod1.b1" with the string "A". Notice that the substring "mod1.b11" should not be replaced with "A".

In other words, the substring "mod1.b1" should be replaced only if it is at the beginning or at the end of the formula, or no number or letter delimit the string.

 

Thanks all

 

 

0 Kudos
Message 1 of 6
(4,324 Views)

I use this regula expression to replace the string if it is at the end or at the beginning of the string:

 

^mod1.b1|mod1.b1$

0 Kudos
Message 2 of 6
(4,309 Views)

It's not possible to search this string "mod1.b1+" and replace this by "StringA+" ?

0 Kudos
Message 3 of 6
(4,300 Views)

Hi,

I write a little logic, may be this is not solve Your problem fully, but think can help You !!!

With Best Regards

Hrachya

Certified LabVIEW Architect (CLA)
0 Kudos
Message 4 of 6
(4,274 Views)

Use the following regex

 

regex solution.png

 

Ben64

Message 5 of 6
(4,253 Views)

AC_85 a écrit :

I use this regula expression to replace the string if it is at the end or at the beginning of the string:

 

^mod1.b1|mod1.b1$


To replace only at beginning or end of the string put a backslash in front of the dot in mod1.b1. In regex a dot match everything so you have to put the escape character \ in front of it if you want to match a dot.

 

Ben64

0 Kudos
Message 6 of 6
(4,242 Views)