LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match case in search and replace string

Solved!
Go to solution

Hi !

 

Attached, my problem.

I am searching "toto" in input string "toto+tototi" and replace "toto" by "A0".

I want to "match case" the search input in order to get a string result : A0+tototi

Does it exist options allowing to match case ?


BR,
Vincent

0 Kudos
Message 1 of 12
(3,640 Views)

Please fill all your controls with typical strings, make the new values the default, save the VI under a new name, and attach it again.

 

(This allows us to quickly reproduce your problem without entering strings and having to guess what your inputs actually are)

 

WIth your given string, the result seems as expected, so we need more information on what you actually want instead.

0 Kudos
Message 2 of 12
(3,637 Views)

All right, my bad...

0 Kudos
Message 3 of 12
(3,632 Views)

Why are you wiring a TRUE to the "replace all?" input? wire a FALSE or don't wire that input at all!.

0 Kudos
Message 4 of 12
(3,627 Views)

In my expression i could have several "toto" in. And i need to replace them all.

That's why i need to find a way to "match case"

 

Look at my final application : result should be 9, not 14 !

Does a match case option exist ?

 

BR,

Vincent

0 Kudos
Message 5 of 12
(3,616 Views)

See, it is not clear what you mean by "match case", because all your strings are lower case. Also, the given example works with the strings you originally provided.

 

I guess you need to parse the string differently, since your tokens share substrings. Do you have a small and known set of delimiters, for example?

 

0 Kudos
Message 6 of 12
(3,607 Views)

Change your Search string to toto\b so you only match toto followed by a word boundary.

Message 7 of 12
(3,592 Views)

Hi Darin,

 

Can you be more specific ? I don't understand what you mean... searching toto\b let me search toto\b. If it is a specific option could you return where did you find it pls ?

 

Altenbach, i don't have any delimiter. All mathematics operators (+-/*sin,cos,tan) could be my delimiters.

I think that i am going to find a way to search and replace the longest name first, then smaller.

Thanks for your ideas.

 

BR,

Vincent

 

0 Kudos
Message 8 of 12
(3,578 Views)
Solution
Accepted by topic author Vincent90

You are using Search and Replace with Regular Expressions selected (the little asterisk on the icon).  \b represents a word boundary, basically the imaginary space between character which is a letter, number or underscore and one which is not.  In other words, it is a zero-width assertion which means that \b does not capture anything.

 

For example:  toto matches toto,toto1,toto_1 etc.  toto\b will only match the string 'toto' when it is followed by something which is not alphanumeric or underscore, that is why it will not match toto1 but will match toto+ or 'toto '.

 

Go to pcre.org for more info, or follow the detailed help in LV.  I assumed you knew because you have to turn on Regular Expressions in S&R so I assumed you had done that.  You probably did without realizing what you were doing.

Message 9 of 12
(3,572 Views)

It probably still needs to be tweaked a little, because the two different strings could match at the right word boundary but still be different. (e.g. atoto, btoto)

Message 10 of 12
(3,563 Views)