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

Are my parentheses just out of place then?

Q: lines of file "C:\Users\me\Desktop\ExampleLog.log" as lowercase
A: 2024-11-22 10:15:18,229 [17] debug devicehandler [-1] - device state set to idle with data not available
A: 2024-11-22 11:09:55,433 [15] info  servicemain - received time changed system event from windows so cached time zone data has been cleared
A: 2024-11-22 11:12:09,525 [31] trace logcontextmessagehandler [d6b53153-8574-b226-c1128fc14a84] - using log context = {path components = [], name components = []}
A: stx=yes&lineitem=processing...

Q: lines whose (it contains "trace" as lowercase) of lines of file "C:\Users\me\Desktop\ExampleLog.log" as lowercase
E: The operator "lines" is not defined.

No, it’s that you’re basically retrieving “lines of lines of file” instead of “lines of file”. You need to just move your filter and only reference lines whose (it as lowercase ...) of file

Try: lines whose (it contains "trace" as lowercase) of file

1 Like

Ah ha! Didn’t think of casting within the whose… THANKS!

1 Like

Thanks; had tried that and got a blank A: :melting_face: