I am trying to search a file for lines that have TWO individual entries in the line. Essentially i want to know if a string is in the line however if the line is commented out i would like to ignore it … some what of an and statement for hte search Here is what i have that works for ONE string search found in hte file but i cannot figure out how to put two in there. The second thing MUST be on hte same line as hte first thing
blah blah blah SKL ENGAGE (should return to me)
’ blah blah blah SKL ENGAGE (should not count because its commented out
if exists folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of the registry as string & “\config”) then if number of files whose (content of it as lowercase contains “skl engage”) of folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of the registry as string & “\ct_src”) > 0 then concatenation “,” of names of files whose (content of it as lowercase contains “skl engage”) of folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of the registry as string & “\ct_src”) as string else “” else “”
basically if the whole file has SKL ENGAGE i want to report it … anywhere in the file, however if hte line that it finds it on has a ’ at the begenning then dont count it
if (not exists folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of registry as string & “\config”)) then “” else (if (length of it > 0) then it else “”) of (concatenation ", " of (names of (files of folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of registry as string & “\config”) whose (exists lines whose (it as lowercase contains “skl engage” and it does not start with “’”) of it)))
Q: if (not exists folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of registry as string & “\config”)) then “” else (if (length of it > 0) then it else “”) of (concatenation ", " of (names of (files of folder (“C:\SC” & value “Active” of key “HKEY_LOCAL_MACHINE\SOFTWARE\bob\Install\MachineController” of registry as string & “\config”) whose (exists lines whose (it as lowercase contains “skl engage” and it does not start with “’”) of it))))
E: The expression could not be evaluated for an unknown reason
I noticed that you were unbalanced on the () so i tried to find wehre it went and it seemed to fit at the end so i added it there but it doesnt get anything other than the above one… the first part works i broke it out and it gives no ct_src folder if it doesnt exist but the rest i dont know how to test individually
Yeah, I hacked that together without testing it and missed a (). This should work, if you are succesfully able to replace (“C:”) with the folder you want.
q: if (not exists folder (“C:”)) then “” else (if (length of it > 0) then it else “”) of (concatenation ", " of (names of (files of folder (“C:”)) whose (exists lines whose (it as lowercase contains “skl engage” and it does not start with “’”) of it)))
A:
q: if (not exists folder (“C:\Users\Noah Salzman”)) then “” else (if (length of it > 0) then it else “”) of (concatenation ", " of (names of (files of folder (“C:\Users\Noah Salzman”)) whose (exists lines whose (it as lowercase contains “skl engage” and it does not start with “’”) of it)))
Well, if you know for certain that the apostrophe is always going to be right in front of the “skl” then you can do something like this:
Q: (it contains “skl” and it does not start with “’” and it does not contain “'skl”) of " skl"
A: True
Q: (it contains “skl” and it does not start with “’” and it does not contain “'skl”) of “’ skl”
A: False
Q: (it contains “skl” and it does not start with “’” and it does not contain “'skl”) of " 'skl"
A: False
Q: (it contains “skl” and it does not start with “’” and it does not contain “'skl”) of " ’ skl"
A: True
Note that the last example is a case that we can’t handle by simply adding
and it does not contain “'skl”
.
Trimmed string will only take off trailing white space, so if you need to handle the last case – where the apostrophe may have leading and trailing whitespace – then we probably have to use regex.