====== ReplaceBetween(text, string1, contents, string2 [,N]) ======
Category:  Text function

\\ 
=====Description=====
This function replaces the characters between //string1// and //string2// in //text// with //contents//.

\\ 
=====Use cases=====
This function can be used for patching or editing HTML/XML data.

\\ 
=====Arguments=====
^Argument^Type^Description^
|text|Text (must //not// be empty)|The initial text value.|
|string1|Text (must //not// be empty)|The text string that defines the //starting 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.|
|N |Number (optional)|This value defines which occurrence to replace.  If omitted, N defaults to 1/first.|

**Return value type:** Text

\\ 
=====Remarks=====
This function is case-sensitive.

//text//, //string1//, //string2// and //contents// are implicitly converted to text values if required.

If either //string1// or //string2// is not found within //text//, the original //text// string is returned.\\

Only the text string between //the first occurrence// of the //string1// and //string2// pair is replaced.  Any other occurrences are ignored.  See the last Example, below.

\\ 
=====Examples=====
  replacebetween('<b>123</b>', '<b>', 'ABC', '</b>') //Returns '<b>ABC</b>'

  replacebetween('<b>123</b>', '<u>', 'ABC', '</b>') //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 'aBC_aBC' (case-sensitive; 'A' not found)


\\ 
===== See also =====
  * [[syntax:functions:regexreplace|RegExReplace(text, replace_text, regex_text)]]
  * [[syntax:functions:replace|Replace(text, string_old, string_new)]]
  * [[syntax:functions:replacebetweenmany|ReplaceBetweenMany(text, string1, contents, string2 [,N])]]