“/” is not part of a regular expression, not in the context of /.*
/.
“/” is the delineator for regular expressions in some contexts (notable Perl), that is, you would have /regex/ where “regex” is the regular expression.
Unless you want to match an explicit “/” character, you would not use them in a regular expression in Keyboard Maestro.
@JMichaelTX’s Search Clipboard is a good solution, and you just need to use the expression (.*
) (your .*
expression will match the first line (since . matches any character except end of line characters normally), but you need the brackets to “capture” the match).
They can also be “scoped” within a non-capturing bracket, let this:
\A(.+)(?s:.+)
This would match the entire string (assuming it had started with at least one non-end-of-line character, and contained at least two characters) and would capture the non-end-of-line characters at the start.
The \A is redundant in this case. However if the string might start with an end-of-line character, then the match will fail with the \A or return the first line after leading end-of-line characters without it. Similarly, the match will fail for a single character, or if there are no end-of-line characters, then it will return the first (only) line minus the last character, so better is:
(.*)(?s:.*)
which will always match, and will return the first non-blank line (or an empty string) as the first capture, but may not match the entire string (thus works better with the Search Clipboard than the Search & Replace Clipboard.
You could also do this:
(?s:.*?)(.*)(?s:.*)
which will always match, and will return the first non-blank line (or an empty string) as the first capture, and always match the entire string.
Understanding the meaning of the (?s:REGEX) and the “*?
” non-greedy match if worthwhile for extending your regex knowledge.
Regex, a bit like Keyboard Maestro, goes off into infinity. You don’t need to know it all, but the more you know the more options you have available to you.