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 revisionPrevious revision
Next revision
Previous revision
Regular_Expressions [2021/10/20 02:34] – peternlewisRegular_Expressions [2026/10/08 02:41] (current) – peternlewis
Line 17: Line 17:
 ===== Search Modifiers ===== ===== Search Modifiers =====
  
-The ICU calls these modifiers "[[https://www.keyboardmaestro.com/action/linkthru?regularexpressionreferenceflags|flag options]]".+The ICU calls these modifiers [[https://www.keyboardmaestro.com/action/linkthru?regularexpressionreferenceflags|flag options]].
  
-The search modifier "Pattern to Use" shown below is placed at the very beginning of the Search/Find Regular Expression box.\\   
-For example:\\  
-`(?m)^\s*\d+[\t]+`\\ 
-as shown in the below example #1. 
  
 ^Purpose^Pattern to Use^Description^ ^Purpose^Pattern to Use^Description^
Line 31: Line 27:
 |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.|
 +
 +Note that matches are **case sensitive** by default (unless the action offers an //ignores case// option), so you can use (?i) to make the regular expression case insensitive.
 +
 +The search modifier can apply to a section of the regular expression by using the form:
 +
 +```
 +Case Sensitive (?i:case insensitive) Case Sensitive
 +```
 +
 +of the search modifier can apply for the remainder of the pattern (unless changed later) like this:
 +
 +```
 +Case Sensitive (?i)case insensitive case insensitive
 +```
 +
 +or
 +
 +```
 +Case Sensitive (?i)case insensitive (?-i) Case Sensitive
 +```
 +
 +For example to search for the start of a line anywhere within the pattern, for the text "Hello THERE" where THERE is case insensitive you could use:
 +
 +```
 +(?m)^Hello(?i:there)
 +```
 +
 +Note that `(?…)` is not a Capture Group.
  
  
Line 81: Line 105:
 Sometimes you may need to extract a RegEx Capture Group after a match is made, and do this for multiple lines (matches) in the entire source string.  To achieve this, you need to: Sometimes you may need to extract a RegEx Capture Group after a match is made, and do this for multiple lines (matches) in the entire source string.  To achieve this, you need to:
  
-1. Use the [[action:For_Each|For Each Action]] to get each match into a variable (MatchString) +1. Use the [[action:For_Each|For Each Action]] with the [[collection:Substrings_In|Substrings In]] collection to get each match into a variable (Local MatchString). 
-2. Then use a [[action:Search_Variable|Search Variable Action]] to get the Capture Group for that match+2. Then use a [[action:Search_using_Regular_Expression|Search using Regular Expression]] action to get the Capture Group for that match.
  
 Both Actions can use the same RegEx pattern. Both Actions can use the same RegEx pattern.
  
-{{:km-for-each-regex-example.png?nolink|}}\\ 
  
-For a complete macro using this method, see:\\ +{{:km-for-each-regex-example.png?nolink|}} 
-[MACRO: Get List of RegEx Capture Group of Multiple Matches](https://forum.keyboardmaestro.com/t/macro-get-list-of-regex-capture-group-of-multiple-matches/2975)+ 
 +For a complete macro using this method, see: [MACRO: Get List of RegEx Capture Group of Multiple Matches](https://forum.keyboardmaestro.com/t/macro-get-list-of-regex-capture-group-of-multiple-matches/2975)
  
  
Line 163: Line 187:
 ==== Online Primers & Tutorials ==== ==== Online Primers & Tutorials ====
  
-  - [[http://www.agillo.net/regex-primer-part-1/|Regex Primer : Part 1]] 
-  - [[http://www.agillo.net/regex-primer-part-2/|Regex Primer : Part 2]] 
   - [Regular Expressions Quick Start](http://www.regular-expressions.info/quickstart.html)   - [Regular Expressions Quick Start](http://www.regular-expressions.info/quickstart.html)
   - [[http://www.codeproject.com/KB/dotnet/regextutorial.aspx|CodeProject.com RegExTutorial]]   - [[http://www.codeproject.com/KB/dotnet/regextutorial.aspx|CodeProject.com RegExTutorial]]
  
 Keywords:  //Regular Expression, RegEx, RegExp, Find, Replace, Match// Keywords:  //Regular Expression, RegEx, RegExp, Find, Replace, Match//
Regular_Expressions.1634697296.txt.gz · Last modified: by peternlewis

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki