10-17-2014 10:08 AM
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
Solved! Go to Solution.
10-17-2014 10:11 AM - edited 10-17-2014 10:15 AM
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.
10-17-2014 10:15 AM
All right, my bad...
10-17-2014 10:17 AM
Why are you wiring a TRUE to the "replace all?" input? wire a FALSE or don't wire that input at all!.
10-17-2014 10:25 AM
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
10-17-2014 10:38 AM
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?
10-17-2014 11:07 AM
Change your Search string to toto\b so you only match toto followed by a word boundary.
10-17-2014 12:09 PM
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
10-17-2014 12:19 PM
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.
10-17-2014 12:35 PM
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)