User Tools

Site Tools


action:Search_and_Replace

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
action:Search_and_Replace [2021/10/14 04:01]
peternlewis
action:Search_and_Replace [2023/09/12 05:30] (current)
peternlewis
Line 3: Line 3:
 Prior to v8.0 there were separate Search and Replace Variable and Search and Replace Clipboard actions and the results always went back to the source variable or clipboard. Prior to v8.0 there were separate Search and Replace Variable and Search and Replace Clipboard actions and the results always went back to the source variable or clipboard.
  
-{{:​action:​searchreplace.png?​nolink&516|}}+{{:​action:​searchreplace.png?​nolink|}}
  
 You can search for: You can search for:
Line 37: Line 37:
  
 {{:​action:​search-replace-example-result.png?​nolink&​511|}} {{:​action:​search-replace-example-result.png?​nolink&​511|}}
 +
 +Note that you can use tokens in the replace field (eg `%Variable%Whatever%`),​ but that when those tokens are expanded, the contents will themselves not be further expanded, so, for example you could not have a variable that contains `$1` and expect that to be replaced by a the corresponding capture group. You could use an AppleScript like this:
 +
 +```applescript
 +tell application "​Keyboard Maestro Engine"​
 + set src to getvariable "​Source"​
 + set s to getvariable "​Search"​
 + set r to getvariable "​Replace"​
 + set o to search src for s replace r with regex
 +end tell
 +```
  
 ===== See Also ===== ===== See Also =====
action/Search_and_Replace.1634198518.txt.gz ยท Last modified: 2021/10/14 04:01 by peternlewis