Going through PowerShell logs, I'm attempting to extract the commands while discarding the path the command was ran from. For example,
PS C:\Windows\system32> pwd
I'd only like to return pwd. I know this can be accomplished with .split, but I'm struggling to get the regex working. The path will vary, so building a regex off a specific path will not work. My attempt right now is to match the string between "PS" and "> ", such as the regex here (?<=(PS)).*(?=(> )). However this causes unintended results when the path has the letters 'ps' in it.
Splitting off of > is not wanted either, since if a command has > in it then I don't want to trim the actual command.