Difference between revisions of "STR REPLACE()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 8: Line 8:
  
 
==Syntax==
 
==Syntax==
STR_REPLACE(<expC1>, <expC2>, <expC3> | <memofield>)
+
STR_REPLACE(<expC1>, <expC2>, <expC3> | <memofield> [, <expN>])
  
  
Line 18: Line 18:
 
The STR_REPLACE() function will search <expC3> or <memofield> and replace text within <expC3> or <memofield> with <expC2> wherever the occurrence of <expC1> is found.  The STR_REPLACE() function returns a character expression that contains the result of the string replacement.
 
The STR_REPLACE() function will search <expC3> or <memofield> and replace text within <expC3> or <memofield> with <expC2> wherever the occurrence of <expC1> is found.  The STR_REPLACE() function returns a character expression that contains the result of the string replacement.
  
NOTE: The PHP numeric count argument to return the number of matched and replaced <expC1> strings is not supported.   
+
The optional count argument, <expN>, can be used to return the number of matched and replaced <expC1> strings.   
  
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
? str_replace("ello", "i","Hello World")
+
? str_replace("ello", "i","Hello World",nCount)
 
Hi World
 
Hi World
 +
? nCount
 +
        1
 
</code>
 
</code>
  

Revision as of 11:52, 22 October 2009

Class

String Data


Purpose

Function to search for and replace text within a character string or memo field


Syntax

STR_REPLACE(<expC1>, <expC2>, <expC3> | <memofield> [, <expN>])


See Also

AT(), ATNEXT(), CHRTRAN(), INLIST(), LEFT(), OCCURS(), RAT(), RIGHT(), STR(), STREXTRACT(), STRTRAN(), STUFF(), SUBSTR()


Description

The STR_REPLACE() function will search <expC3> or <memofield> and replace text within <expC3> or <memofield> with <expC2> wherever the occurrence of <expC1> is found. The STR_REPLACE() function returns a character expression that contains the result of the string replacement.

The optional count argument, <expN>, can be used to return the number of matched and replaced <expC1> strings.


Example

? str_replace("ello", "i","Hello World",nCount)
Hi World
? nCount
         1


Products

Recital Server, Recital