User Tools

Site Tools


Regular_Expressions

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
Regular_Expressions [2017/03/05 22:35]
peternlewis
Regular_Expressions [2018/04/09 00:06]
JMichaelTX ADD update to Capture Groups
Line 6: Line 6:
  
  
-In Keyboard Maestro ​Actions, if the term "​matches"​ is used, it means that it supports regular expression. ​ However, there are many Actions in Keyboard Maestro where you can use a regular expression, which may not be obvious. ​ For more info see [Places where Regular Expressions can be used](https://​forum.keyboardmaestro.com/​t/​places-where-regular-expressions-can-be-used/​4392).+In any [[Actions|Action]] where the term "​matches"​ is used, you may (optionally) ​use a regular expression.
  
  
-----+**The two most commonly used RegEx Actions are:** 
 +  * [[action:​Search_using_Regular_Expression|Search using Regular Expression ]] to extract [[https://​www.regular-expressions.info/​brackets.html | Capture Groups]]. 
 +  * [[action:​Search_and_Replace|Search and Replace]]
  
 +In all of the RegEx searches, you can choose to search in any one of the following: System Clipboard, Variable, File, Text entered into the Action, and Named Clipboard.
  
-===== Capture Groups =====+There are many Actions in Keyboard Maestro where you can use a regular expression, which may not be obvious. ​ For more info see [Places where Regular Expressions can be used](https://​forum.keyboardmaestro.com/​t/​places-where-regular-expressions-can-be-used/​4392).
  
-  - Use the form of `$n` in the Action Replace box, where n is the number for the capture group. ​ + 
-  Example: `$1, $2, $3` +----
-  ​This is the same as `\n` used in other apps/​languages.+
  
  
Line 35: Line 37:
 |Word Boundaries|`(?​w)`|Controls the behavior of \b in a pattern.\\ If used, word boundaries are found according to the definitions of word found in [[http://​unicode.org/​reports/​tr29/#​Word_Boundaries|Unicode UAX 29, Text Boundaries]].| |Word Boundaries|`(?​w)`|Controls the behavior of \b in a pattern.\\ If used, word boundaries are found according to the definitions of word found in [[http://​unicode.org/​reports/​tr29/#​Word_Boundaries|Unicode UAX 29, Text Boundaries]].|
 |Comments|`(?​x)`|Ignores white space and allows #​comments.\\ If used, white space within regular expressions is ignored and you can use #​line-comments.| |Comments|`(?​x)`|Ignores white space and allows #​comments.\\ If used, white space within regular expressions is ignored and you can use #​line-comments.|
 +
 +
 +===== Capture Groups =====
 +  * Use the form of `$<​CG#>​`,​ or `\<​CG#>​` (in ver 8+) in the Action Replace box, where `<​CG#>​` is the number for the capture group. ​
 +  * Examples: ​
 +    * `$1, $2, $3`
 +    * `\1, \2, \3`
 +  * This is the same as `\<​CG#>​` used in other apps/​languages,​ like BBEdit.
 +
 +For more information,​ see [[https://​www.regular-expressions.info/​brackets.html | Capture Groups]].
 +
 +
  
 ===== Use of Text Tokens ===== ===== Use of Text Tokens =====
Line 99: Line 113:
  
  
-- [[https://​forum.keyboardmaestro.com/​search?​q=Regular%20Expression%20RegEx|Keyboard Maestro Forum topics about Regular Expressions (RegEx)]]+- [[https://​forum.keyboardmaestro.com/​tags/regex|Keyboard Maestro Forum topics about Regular Expressions (RegEx)]]
  
 ==== General ==== ==== General ====
Regular_Expressions.txt · Last modified: 2022/11/10 03:29 by ccstone