Try:
\b[A-Za-z]+(?=\s(?=ssh|folder|http))
Regex Demo here.
let regex = /\b[A-Za-z]+(?=\s(?=ssh|folder|http))/g;
[match] = "Thu May 23 22:41:55 2019 19 10.10.10.20 22131676 /mnt/tmp/test.txt b s o r John ssh 0 *".match(regex);
console.log(match); //John
[match] = "Thu May 23 22:42:55 2019 19 10.10.10.20 22131676 /mnt/tmp/test.txt b s o i Jake folder 0 *".match(regex);
console.log(match); //Jake
[match] = "Thu May 23 22:41:55 2019 19 10.10.10.20 22131676 /mnt/tmp/test.txt b s o t Steve http 0 *".match(regex);
console.log(match); //Steve
Regex explanation:
\b
defines a word boundary to start match
[A-Za-z]
match any alphabet, any case
+
repeat previous character any number of times till next pattern
(?=
finds lookahead pattern (which won't be included in matching group)
\s
a whitespace
(?=ssh|folder|http)
another lookahead to either ssh
, folder
or http
Putting it all together, the regex looks for a word that is followed by a space and then one of the following: ssh, folder, or http.