User Tools

Site Tools


syntax:functions:replacebetween

Differences

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

Link to this comparison view

syntax:functions:replacebetween [2023/10/14 00:10] – created craigtsyntax:functions:replacebetween [2025/03/18 16:57] (current) – update to include N argument craigt
Line 1: Line 1:
-====== ReplaceBetween(text, string1, contents, string2) ======+====== ReplaceBetween(text, string1, contents, string2 [,N]) ======
 Category:  Text function Category:  Text function
  
Line 17: Line 17:
 |string2|Text (must //not// be empty)|The text string that defines the //ending point// of the text to be replaced.| |string2|Text (must //not// be empty)|The text string that defines the //ending point// of the text to be replaced.|
 |contents|Text (must //not// be empty)|The text string to be inserted between //string1// and //string2//, replacing any existing text.| |contents|Text (must //not// be empty)|The text string to be inserted between //string1// and //string2//, replacing any existing text.|
 +|N |Number (optional)|This value defines which occurrence to replace.  If omitted, N defaults to 1/first.|
  
 **Return value type:** Text **Return value type:** Text
Line 36: Line 37:
   replacebetween('<b>123</b>', '<u>', 'ABC', '</b>') //Returns '<b>123</b>' ('<u>' not found)   replacebetween('<b>123</b>', '<u>', 'ABC', '</b>') //Returns '<b>123</b>' ('<u>' not found)
  
-  replacebetween('<b>123</b>', '<b>', 'ABC', '</u>') //Returns '<b>123</b>' ('</u>' not found) +  replacebetween('ABC_ABC', 'A', 'N', 'C', 2) //Returns 'ABC_ANC' (2nd occurrence is replaced)
- +
-  replacebetween('ABC_ABC', 'A', 'N', 'C') //Returns 'ANC_ABC' (first occurrence is replaced)+
  
   replacebetween('aBC_aBC', 'A', 'N', 'C') //Returns 'aBC_aBC' (case-sensitive; 'A' not found)   replacebetween('aBC_aBC', 'A', 'N', 'C') //Returns 'aBC_aBC' (case-sensitive; 'A' not found)
Line 45: Line 44:
 \\  \\ 
 ===== See also ===== ===== See also =====
 +  * [[syntax:functions:regexreplace|RegExReplace(text, replace_text, regex_text)]]
   * [[syntax:functions:replace|Replace(text, string_old, string_new)]]   * [[syntax:functions:replace|Replace(text, string_old, string_new)]]
 +  * [[syntax:functions:replacebetweenmany|ReplaceBetweenMany(text, string1, contents, string2 [,N])]]
syntax/functions/replacebetween.txt · Last modified: 2025/03/18 16:57 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki