User Tools

Site Tools


syntax:functions:find

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
syntax:functions:find [2021/08/15 02:04] – [Examples] craigtsyntax:functions:find [2026/09/24 11:04] (current) – Added alternative syntax section, examples, other minor changes roberto
Line 7: Line 7:
  
 The first character in //text// has an index of 1. The first character in //text// has an index of 1.
 +
 +\\ 
 +=====Alternative syntax=====
 +This function can take an optional third numeric parameter to define the instance of //look_for// to find.  If //instance_num// is negative, the search starts from the end of //text//.
 +  Find(text, look_for, instance_num)
  
 \\  \\ 
Line 13: Line 18:
 |text|Text|The text value to search within for the //look_for// string.| |text|Text|The text value to search within for the //look_for// string.|
 |look_for|Text|The text string to search for within //text//.| |look_for|Text|The text string to search for within //text//.|
 +|instance_num<sup>*</sup>|Number (non-zero integer)|The occurrence of //look_for// to find.|
 +<sup>*</sup>Optional argument.
  
 **Return value type:** Number **Return value type:** Number
Line 32: Line 39:
  
   find('New York New York', 'York') //Returns 5  (Returns the position of the first instance only)   find('New York New York', 'York') //Returns 5  (Returns the position of the first instance only)
 +
 +  find('New York New York', 'York', 2) //Returns 14  (The second instance)
 +
 +  find('a/b/c/d', '/', 2) //Returns 4  (The second '/' from the start)
 +
 +  find('a/b/c/d', '/', -1) //Returns 6  (The last '/')
 +
 +  find('a/b/c/d', '/', -2) //Returns 4  (The second '/' from the end)
  
   find('New York', 'new') //Returns 0  (Unmatched due to case)   find('New York', 'new') //Returns 0  (Unmatched due to case)
Line 44: Line 59:
   * [[syntax:functions:endswith]|EndsWith(text1, look_for)]]   * [[syntax:functions:endswith]|EndsWith(text1, look_for)]]
   * [[syntax:functions:startswith]|StartsWith(text1, look_for)]]   * [[syntax:functions:startswith]|StartsWith(text1, look_for)]]
- 
syntax/functions/find.txt · Last modified: by roberto

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki