Difference between revisions of "STRTRAN()"

From Lianjapedia
Jump to: navigation, search
 
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
==Syntax==
 
==Syntax==
STRTRAN(<expC1> | <memofield>, <expC2> [, <expC3> [, <expN1> [, <expN2>]]])
+
STRTRAN(<expC1> | <memofield>, <expC2> [, <expC3> [, <expN1> [, <expN2> [, <expN3>]]]])
  
 
==See Also==
 
==See Also==
[[AT()]], [[ATNEXT()]], [[CHRTRAN()]], [[INLIST()]], [[LEFT()]], [[OCCURS()]], [[RAT()]], [[RIGHT()]], [[SET STRESCAPE]], [[STR()]], [[STR_REPLACE()]], [[STREXTRACT()]], [[STUFF()]], [[SUBSTR()]]
+
[[AT()]], [[ATNEXT()]], [[CHRTRAN()]], [[INLIST()]], [[LEFT()]], [[OCCURS()]], [[RAT()]], [[RIGHT()]], [[SET STRESCAPE]], [[STR()]], [[STR_COMPRESS()]], [[STR_REPLACE()]], [[STR_UNCOMPRESS()]], [[STREXTRACT()]], [[STUFF()]], [[SUBSTR()]]
  
 
==Description==
 
==Description==
The STRTRAN() function will search <expC1> or <memofield> and replace text within <expC1> or <memofield> with <expC3> wherever the occurrence of <expC2> is found.  If <expC3> is not specified, instances of the text in <expC2> are removed. The optional <expN1> specifies the start position for the search in <expC1>.  If this is not specified then the default is 1. The optional <expN2> specifies the number of occurrences of <expC2> to replace with <expC3>.  If this is not specified, then all occurrences starting from <expN1> are replaced. This function can be used to remove blank spaces in character strings. The STRTRAN() function returns a character expression that contains the result of the string translation.
+
The STRTRAN() function will search <expC1> or <memofield> and replace <expC2> with <expC3>
 +
 
 +
This function can also be used to remove blank spaces in character strings.  The STRTRAN() function returns a character expression that contains the result of the string translation.
 +
 
 +
 
 +
{|class="wikitable" width="100%"
 +
!width="20%"|Parameters||Required||Description
 +
|-
 +
|valign="top"|<expC1> &#124; <memofield>||valign="top"|Yes||The character expression or memo field to search.
 +
|-
 +
|valign="top"|<expC2>||valign="top"|Yes||The character expression to replace.
 +
|-
 +
|valign="top"|<expC3>||valign="top"|No||The replacement character expression.  If <expC3> is not specified, occurrences of <expC2> are removed.
 +
|-
 +
|valign="top"|<expN1>||valign="top"|No||The start occurrence of <expC2> in <expC1> to replace.  If <expN1> is not specified then the replacement starts from the first (1) occurrence of <expC2>.  
 +
|-
 +
|valign="top"|<expN2>||valign="top"|No||The number of occurrences of <expC2> to replace with <expC3>.  If <expN2> is not specified, then all occurrences starting from <expN1> are replaced.
 +
|-
 +
|valign="top"|<expN3>||valign="top"|No||Flag:<br>0 or -1 = Search is case-sensitive and <expC2> is replaced with <expC3>. (Default)<br>1 = Search is case-insensitive and <expC2> is replaced with <expC3>.<br>2 = Same as 0.<br>3 = Same as 1.
 +
|-
 +
|}
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
? strtran("Hello World", "ello", "i")
+
? strtran("Hello World", "ello", "i",1,1,1)
 
Hi World
 
Hi World
 
</code>
 
</code>
  
==Products==
 
Lianja Server, Lianja
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:String Data]]
 
 
[[Category:String Data Functions]]
 
[[Category:String Data Functions]]

Latest revision as of 12:05, 22 March 2021

Purpose

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

Syntax

STRTRAN(<expC1> | <memofield>, <expC2> [, <expC3> [, <expN1> [, <expN2> [, <expN3>]]]])

See Also

AT(), ATNEXT(), CHRTRAN(), INLIST(), LEFT(), OCCURS(), RAT(), RIGHT(), SET STRESCAPE, STR(), STR_COMPRESS(), STR_REPLACE(), STR_UNCOMPRESS(), STREXTRACT(), STUFF(), SUBSTR()

Description

The STRTRAN() function will search <expC1> or <memofield> and replace <expC2> with <expC3>.

This function can also be used to remove blank spaces in character strings. The STRTRAN() function returns a character expression that contains the result of the string translation.


Parameters Required Description
<expC1> | <memofield> Yes The character expression or memo field to search.
<expC2> Yes The character expression to replace.
<expC3> No The replacement character expression. If <expC3> is not specified, occurrences of <expC2> are removed.
<expN1> No The start occurrence of <expC2> in <expC1> to replace. If <expN1> is not specified then the replacement starts from the first (1) occurrence of <expC2>.
<expN2> No The number of occurrences of <expC2> to replace with <expC3>. If <expN2> is not specified, then all occurrences starting from <expN1> are replaced.
<expN3> No Flag:
0 or -1 = Search is case-sensitive and <expC2> is replaced with <expC3>. (Default)
1 = Search is case-insensitive and <expC2> is replaced with <expC3>.
2 = Same as 0.
3 = Same as 1.

Example

? strtran("Hello World", "ello", "i",1,1,1)
Hi World