User Tools

Site Tools


collection:Substrings_In

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
collection:Substrings_In [2018/05/09 19:56]
JMichaelTX Marked areas that need fixing.
collection:Substrings_In [2021/10/14 03:55] (current)
peternlewis [Actions]
Line 5: Line 5:
 You can look for matches in the System Clipboard, in a Named Clipboard, in a variable, or in a file. You can look for matches in the System Clipboard, in a Named Clipboard, in a variable, or in a file.
  
-You can scan for exact string matches, case insensitive string matches, or regular expression matches.+You can scan for exact string matches, case insensitive string matches, or regular expression matches, or (v10.0+) for strings separated by exact string matches, case insensitive string matches, or regular expression matches.
  
-The result, stored in the [[action:​For_Each| For Each action ]] variable, can be either ​the matched string, the position of the match or the range (position,​length) of the match.+The result, stored in the [[action:​For_Each| For Each action ]] variable, can be either:
  
-So, let's assume you've used a variable ​theRange ​to store the range in a For Each action.+* the matched string: the For Each variable ​is set to the value of the matched string. 
 +* the position of the match: the For Each variable is set to the position of the match (starting at 1). 
 +the range of the match: the For Each variable is set to the range (position,​length) of the match.
  
-It can be referenced by:+For the range option, the variable contains the position and length with a comma between them, so you can use the normal variable array indexing to access the two numbers, eg if the For Each variable is theRange, then theRange[1] would be the position, and theRange[2] would be the length of the match.
  
-theRange[1] +Here's a practical example which superscripts all the numbers in the clipboard.
-theRange[2]+
  
-The range is a comma separated list of values: +{{ :​collection:​for_each_apply_style_to_clipboard.png?nolink&​510 ​Apply Superscript to Numbers in Clipboard ​}}
- +
-n1,n2 +
- +
-OR +
- +
-Start-of-Match,​Length-of-Match +
- +
-So the the normal Keyboard Maestro substring notation works with it. +
- +
-It's all too easy to get misdirected into thinking the numbers reference match 1, match 2 – but this is not the case.\\ +
-FIXME -- Peter, then how are the numbers obtained? ​ Detailed example please. +
- +
-Here's a practical example +
- +
-{{ :​collection:​for_each_apply_style_to_clipboard.jpg?nolink |}} +
- +
-FIXME -- the above screenshot needs correcting or clarifying. ​ Where does the Variable "​Verse"​ come from?  It seems to me that it should be the variable "​matchVar",​ which is set at the top of the "For Each" Action. ​ Also, to be meaningful, you need to show the source data that is being used by the "For Each" Action.+
  
 ===== See Also ===== ===== See Also =====
Line 40: Line 24:
  
 * [[action:​For_Each|For Each]] * [[action:​For_Each|For Each]]
 +* [[:​Actions|See all Actions]]
  
collection/Substrings_In.1525910174.txt.gz · Last modified: 2018/05/09 19:56 by JMichaelTX