annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

Match case in search and replace string

Risolto!
Vai alla soluzione

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
Messaggio 1 di 12
5.240Visualizzazioni

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
Messaggio 2 di 12
5.237Visualizzazioni

All right, my bad...

0 Kudos
Messaggio 3 di 12
5.232Visualizzazioni

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

0 Kudos
Messaggio 4 di 12
5.227Visualizzazioni

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
Messaggio 5 di 12
5.216Visualizzazioni

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
Messaggio 6 di 12
5.207Visualizzazioni

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

Messaggio 7 di 12
5.192Visualizzazioni

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
Messaggio 8 di 12
5.178Visualizzazioni
Soluzione
Accettato da autore argomento 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.

Messaggio 9 di 12
5.172Visualizzazioni

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)

Messaggio 10 di 12
5.163Visualizzazioni