January 11, 2023, 11:36am
The attached search and replace with regex macro works fine. My problem is that it works only on the first line of a list.
how could I add an action that specifies "for each line".?
I was thinking of creating 2 macros, one which ignores empty lines and the other that works on empty lines (when I am adding a prefix for example)
Thank you very much
Search Replace w Regex FORUM VERSION.kmmacros (21.3 KB)
January 11, 2023, 12:31pm
You're forgetting that Keyboard Maestro doesn't have multi-line turned on by default.
You have to add
(?m) to the beginning of your regular expression.
January 11, 2023, 6:50pm
Thank you Chris. The following does not work, even for the first line. Where is my mistake ?
My input in ^(for start of line)
replaced with Monday (on each line)
January 11, 2023, 6:51pm
thanks very much. It above my level. I will attempt to dissect your macro. I am very grateful for your time.
January 11, 2023, 8:08pm
You forgot the parentheses...
January 11, 2023, 8:18pm
sorry but it still does not work. Nothing happens. Would you see any obvious problem. I added clipboard seed but it did not help
User Input I search for ^ (start of line) and replace with monday
thanks and sorry for pestering you
January 11, 2023, 8:20pm
Post the actual macro please.
January 11, 2023, 8:24pm
Sorry, I should have done it in the first place.
Search Replace w Regex.kmmacros (22.8 KB)
January 11, 2023, 9:03pm
You had placed
(?m) in both the search and replace fields – and you had placed a space after it and before the body of the regular expression.
Try mine with the hotkey trigger and see if it works.
Note that the
(?m) has been placed in the user-input dialog.
20)Search Replace w Regex.kmmacros (5.5 KB)
January 11, 2023, 9:25pm
Why does this asynchronous helper macro fail when looking for the user input dialog title, but it works when using the front window
Since we can't depend upon there only being one KM window open, we need to be able to discriminate.
Peter Test Group Macros.kmmacros (5.7 KB)
January 11, 2023, 9:38pm
OK. Now I understand. thanks very much !
Front Window condition explicitly excludes background applications, so it will never apply to the Keyboard Maestro Engine, regardless of any other settings. If you select a background only application by force (like you have done in selecting the Keyboard Maestro Engine), then it will apply to the front application instead.
January 12, 2023, 12:39pm
Ah, so that's what it was doing...