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 [2018/07/09 00:08]
peternlewis Alternate Expressions
Regular_Expressions [2020/09/26 23:42]
JMichaelTX [Search Modifiers] Clarify the "Global" search modifier.
Line 27: Line 27:
  
 ^Purpose^Pattern to Use^Description^ ^Purpose^Pattern to Use^Description^
-|Global|NONE|All searches are global in Keyboard Maestro.\\ This is often indicated in other tools by the `/g` modifier.|+|Global|NONE|The [[action:​Search_using_Regular_Expression|Search using Regular Expression Action]] will return the _first_ match it finds in the source string.\\ ​ In order to make it be a "global" search, you need to put this Action in a [[action:​For_Each|For Each Action]] that uses the [[collection:​Substrings_In|Substrings Matching in]] Collection. ​ This will loop through all matches found in the source string.\\ This is often indicated in other tools by the `/g` modifier.|
 |Case Insensitive|`(?​i)`|Matching will be in a case-insensitive manner.\\ ​ In some Actions this is NOT necessary since the Action already provides an "​ignoring case" option.| |Case Insensitive|`(?​i)`|Matching will be in a case-insensitive manner.\\ ​ In some Actions this is NOT necessary since the Action already provides an "​ignoring case" option.|
 |Dot includes EOL|`(?​s)`|A "​`.`"​ in a pattern will match a line terminator in the input text. Note that a CR LF pair in text behave as a single line terminator, and will match a single "​."​ in a RE pattern.| |Dot includes EOL|`(?​s)`|A "​`.`"​ in a pattern will match a line terminator in the input text. Note that a CR LF pair in text behave as a single line terminator, and will match a single "​."​ in a RE pattern.|
Line 62: Line 62:
  
 These Metacharacters offer some powerful solutions to long-standing RegEx problems. These can replace complicated RegEx patterns previously required, and are recommended for use if you are running the required versions. ​ For example, `\h` and `\R`.  ICU 55 is _not_ available in all RegEx engines. ​ A notable exception is JavaScript (and JXA), even in High Sierra. ​ So if you are using the native Keyboard Maestro Actions that use RegEx, it would be available, but not necessarily in Actions that use Execute Script in another language. ​ It is available in Execute AppleScript Actions that use ASObjC RegEx. These Metacharacters offer some powerful solutions to long-standing RegEx problems. These can replace complicated RegEx patterns previously required, and are recommended for use if you are running the required versions. ​ For example, `\h` and `\R`.  ICU 55 is _not_ available in all RegEx engines. ​ A notable exception is JavaScript (and JXA), even in High Sierra. ​ So if you are using the native Keyboard Maestro Actions that use RegEx, it would be available, but not necessarily in Actions that use Execute Script in another language. ​ It is available in Execute AppleScript Actions that use ASObjC RegEx.
- 
-[FIXME: ​ Need to confirm and complete Alternate Expressions] 
  
 ^   New Metacharacters in ICU 55+(([ICU Regular Expression Metacharacters](http://​userguide.icu-project.org/​strings/​regexp#​TOC-Regular-Expression-Metacharacters))) ​  ^^^ ^   New Metacharacters in ICU 55+(([ICU Regular Expression Metacharacters](http://​userguide.icu-project.org/​strings/​regexp#​TOC-Regular-Expression-Metacharacters))) ​  ^^^
Line 69: Line 67:
 | `\h` | `[^\S\r\n\f]` | Match a Horizontal White Space character.\\ They are characters with Unicode General Category of Space_Separator plus the ASCII tab (\u0009). | | `\h` | `[^\S\r\n\f]` | Match a Horizontal White Space character.\\ They are characters with Unicode General Category of Space_Separator plus the ASCII tab (\u0009). |
 | `\H` | `[\S\r\n\f]` | Match a non-Horizontal White Space character. | | `\H` | `[\S\r\n\f]` | Match a non-Horizontal White Space character. |
-| `\k<​name>​` | TBD | Named Capture Back Reference. |+| `\k<​name>​` | //No Alternative// ​| Named Capture Back Reference. |
 | `\R` | `(?:​\r?​\n|\r)` | Match a new line character, or the sequence CR LF.\\ The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029 | | `\R` | `(?:​\r?​\n|\r)` | Match a new line character, or the sequence CR LF.\\ The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029 |
 | `\v` | `[\n\r]` | Match a new line character.\\ The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029.\\ Does not match the new line sequence CR LF. | | `\v` | `[\n\r]` | Match a new line character.\\ The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029.\\ Does not match the new line sequence CR LF. |
Line 140: Line 138:
 ==== Software ==== ==== Software ====
  
-  ​[[http://​www.barebones.com/​products/​textwrangler/|TextWrangler (a freeware text editor ​with PCRE regular expression support)]] +  ​[[http://​www.barebones.com/​products/​bbedit/|BBEdit]] -- A Programming Editor ​with PCRE regular expression support.      
-  ​[[http://​itunes.apple.com/​us/​app/​patterns-the-regex-app/​id429449079?​mt=12|Patterns ​— a regular expression analyzer on the app-store]] +    * The commercial demo expires in 30 days and reverts to the still //very// powerful BBEdit-Lite (freeware)
-  ​[[https://​itunes.apple.com/​us/​app/​regexrx/​id498370702?​mt=12|RegExRX ​— a regular expression analyzer on the app-store]] +''''​ 
-  ​[[https://​regex101.com|RegEx101.com]] -- Online RegEx Analyzer+ 
 +  ​[[http://​itunes.apple.com/​us/​app/​patterns-the-regex-app/​id429449079?​mt=12|Patterns]] -- A regular expression analyzer ​available ​on the app-store. 
 +  ​[[https://​itunes.apple.com/​us/​app/​regexrx/​id498370702?​mt=12|RegExRX]] -- A regular expression analyzer ​available ​on the app-store
 + 
 +  ​''''​ 
 + 
 +  * [[https://​regex101.com|RegEx101.com]] -- An Outstanding and Comprehensive ​Online RegEx Analyzer
 +  * [[http://​regexr.com/​|Regexr]] -- Regex testing and explaining, examples and references.
  
 ==== Books ==== ==== Books ====
Line 163: Line 168:
   - [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]]
-  - [[http://​regexr.com/​|Regexr ​ - Regex testing and explaining, examples and references]] 
  
 Keywords: ​ //Regular Expression, RegEx, RegExp, Find, Replace, Match// Keywords: ​ //Regular Expression, RegEx, RegExp, Find, Replace, Match//
Regular_Expressions.txt · Last modified: 2022/11/10 03:29 by ccstone