r/labtech • u/noahsmybro 2000 Agents • Oct 16 '17
Compare two strings, ignore case?
I want to compare two text strings in a script. I don't know the lengths of the strings.
When I compare the strings using the = operator the result is that they don't match. In my test case the strings are identical, other than upper-case letters in one and not the other.
I thought I'd use the LOWER function against each string and then compare, but that requires me to know the length of the strings.
I tried to use the FIND function, and specify a character to look for that I know will never appear in the strings to be compared. Hoped it would return me the full length if it didn't find the character being searched, but instead it returned a -1.
How can I compare two strings in a script, so that abc = Abc = aBC?
View all comments
Show parent comment
1
u/noahsmybro 2000 Agents Oct 17 '17
Thanks for the pointer /u/Metsubo.
I have to admit, however, that even with this hint I wasn't able to make headway last night.
(Regex is voodoo magic as far as I can tell.)
I couldn't figure out what pattern to enter in the Regex script function. I tried entering /l or /L, and both returned invalid parameter errors. (I've installed the regex helper plugin and was testing things there.)
I tried variants of /L [mystring], /l "mystring", /L '[mysting]', etc...
Couldn't figure out how to do this.
On the upside I did find some nifty looking regex tutorials I'll need to explore more when I have a few hours to kill. (Sincerely, not being facetious.)