Remove Spaces from Line

I have a line that looks like this, and I would like to get rid of the spaces and put a “/” between them.

             False                                    True

The answer would be:

False/True

I tried the following, but get too many “/”.

(concatenation "/" of substrings separated by " " of it) of ((lines whose ((it as lowercase contains "false") or (it as lowercase contains "true")) of file "c:\windows\smb-status.txt") as trimmed string)

With multiple spaces between the tokens, you’ll need to have some logic to discard the blank results. I’m away from a computer right now, but I think something like

(concatenation "/" of (substrings separated by " ") whose (it as trimmed string != "") of it) of lines ...
1 Like

It did not work: the property ‘substrings separated by string’ is not defined

This code works. Thanks Jason!

concatenation "/" of ((substrings separated by " " of it) whose (it as trimmed string != "")) of lines whose (it as lowercase contains "false" or it as lowercase contains "true") of file "c:\Windows\SMB-Status.txt"
2 Likes
Q: concatenation "/" of parenthesized parts of matches (case insensitive regex "(True|False)") of "             False                                    True     "
A: False/True

or if you only want lines that contain either true or false modified and everything else returned as-is:

Q: (if (item 0 of it != "") then (item 0 of it) else (item 1 of it)) of (concatenation "/" of parenthesized parts of matches (case insensitive regex "(True|False)") of it, it) of lines of file "C:\Windows\SMB-Status.txt"
2 Likes

Wow! that is some crazy relevance. I had not seen “parenthesized parts of matches” before.

Thanks for the reply.

1 Like