User Tools

Site Tools


action:Search_Variable

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
Next revision Both sides next revision
action:Search_Variable [2015/07/12 21:16]
mirazjordan Amplified with examples
action:Search_Variable [2017/03/05 21:43]
peternlewis [Forum]
Line 1: Line 1:
-The Search Variable action allows you to search a variable for a regular expression and capture what you find to one or more variables. This can be very useful for splitting apart the contents of a variable.+The Search Variable action allows you to search a variable for a [[:Regular Expressions|regular expression]] and capture what you find to one or more variables. This can be very useful for splitting apart the contents of a variable.
  
 {{:​action:​searchvariable.png|}} {{:​action:​searchvariable.png|}}
Line 12: Line 12:
  
 Select where to save results with the //and save capture groups to Variables// pop-up. Depending on the nature of your search you may simply be presented with an //All// option, or with the opportunity to save multiple results to multiple variables. Select where to save results with the //and save capture groups to Variables// pop-up. Depending on the nature of your search you may simply be presented with an //All// option, or with the opportunity to save multiple results to multiple variables.
 +
 +If the search fails, by default (7.1+) the action will abort the macro and notify you of the failure. ​ The destination variables will not be modified. ​ You can turn off aborting the macro and/or notifying you in the gear menu (the destination variables will still not be modified in this case).
  
 Examples: Examples:
-  * Use a regular expression to search through a product price list and save only certain parts of it. Given a line like +  * Use a regular expression to search through a product price list and save only certain parts of it.  
 + 
 + 
 +Given a line like  
 //​SKU1234 Widget 1 $12.95// ​ //​SKU1234 Widget 1 $12.95// ​
 +
 this could look like the following: this could look like the following:
  
 Search for: (SKU\d{4})\t(.+)\t(.+) Search for: (SKU\d{4})\t(.+)\t(.+)
-And capture: the first and third bracketed items to save only the SKU number and the price. To work through a list you would need to include a loop or repeat of some kind. + 
 +And capture: the first and third bracketed items to save only the SKU number and the price. ​ 
 + 
 +To work through a list you would need to include a loop or repeat of some kind. 
  
 {{:​action:​searchvariableexample.png|}} {{:​action:​searchvariableexample.png|}}
Line 27: Line 37:
 {{:​action:​searchvariableresult.png|}} {{:​action:​searchvariableresult.png|}}
  
 +===== See Also =====
 +
 +----
 +
 +=== Actions ===
 +
 +* [[action:​Search Clipboard|Search Clipboard]]
 +* [[action:​Search Variable|Search Variable]]
 +* [[:​Actions|See all Actions]]
 +
 +==== Topics ====
 +
 +* [[:Regular Expressions|Regular Expressions]]
 +
 +----
 +
 +==== Forum ====
 +
 +- [[https://​forum.keyboardmaestro.com/​t/​extracting-substring-of-a-variable/​3007/​2|Extracting substring of a Variable]]
 +
 +- [[https://​forum.keyboardmaestro.com/​search?​q=Search%20Variable|Keyboard Maestro Forum topics about Search Variable]]
action/Search_Variable.txt · Last modified: 2017/09/07 04:10 by peternlewis