Help needed with "as string as lowercase" in TXT file

If I understand things correctly, “as string as lowercase” allows me to check a string regardless of case by converting it to lowercase before doing the comparison. Is this correct?

If so. here is my Issue:

Text file line I am looking for: “Foo_As_Bar = xxx” or Foo_as_Bar = xxx" (The “as” may be in either case in the file)

Text in file: "Foo_As_Bar"
Q: lines whose ( it as string as lowercase contains “Foo_As_Bar” ) of file "C:\temp\text.txt"
A: empty result

Text in file: "Foo_as_Bar"
Q: lines whose ( it as string as lowercase contains “Foo_as_Bar” ) of file "C:\temp\text.txt"
A: empty result

Text in file: "Foo_As_Bar"
Q: lines whose ( it as string contains “Foo_As_Bar” ) of file "C:\temp\text.txt"
A: “Foo_As_Bar = xxx”

Text in file: "Foo_as_Bar"
Q: lines whose ( it as string contains “Foo_as_Bar” ) of file "C:\temp\text.txt"
A: “Foo_as_Bar = xxx”

Where did i go wrong?

Cheers,
Emil

This will do the trick:

lines whose ( it as string as lowercase contains “foo_as_bar” ) of file "C:\temp\text.txt"
2 Likes

Just to expand on that, “as lowercase” is not some kind of special directive on the comparison; it’s just taking the string and changing it to a lowercase form. When we use this to perform case-insensitive comparisons, we have to convert both sides of the comparison operation (or enter our literal string in the correct lowercase).

Comparing two strings in mixed-case results in a False

q: "hELlO" = "HeLlO"
A: False
T: 0.103 ms
I: singular boolean

By using the ‘as lowercase’ cast, we can convert the string to it’s all-lowercase form

q: "hELlO" as lowercase 
A: hello
T: 0.087 ms
I: singular string

If we compare an all-lowercase string to a mixed-case string, it’s still False

q: "hELlO" as lowercase = "HeLlO"
A: False
T: 0.071 ms
I: singular boolean

But if we convert both strings to all-lowercase, they are now equivalent

q: "hELlO" as lowercase = "HeLlO" as lowercase
A: True
T: 0.037 ms
I: singular boolean

(we can also get the same effect with the ‘as uppercase’ cast, if you prefer to be shouty)

q: "hELlO" as uppercase = "HELLO"
A: True
T: 0.041 ms
I: singular boolean
1 Like

I understood the conversion part but failed to grasp the need for both sides to be cast in the same case. Makes sense now.

Thanks,
Emil

1 Like