Replace: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "REPLACE(''target'', ''find'', ''source''[, ''start''[, ''count''[, ''compare'']]]) '''Description''' REPLACE returns a string which has had one substring replaced by another...")
 
No edit summary
Line 1: Line 1:
REPLACE(''target'', ''find'', ''source''[, ''start''[, ''count''[, ''compare'']]])
Replace(''target'', ''find'', ''source''[, ''start''[, ''count''[, ''compare'']]])


'''Description'''
== Description ==


REPLACE returns a string which has had one substring replaced by another a specified number of times. The required parameter, ''target'', is a string expression containing the substring to replace. The required parameter, ''find'', is the string expression to be replaced. The required parameter, ''source'', is the string expression used as the replacement. The optional parameter, ''start'', is a numeric expression that specifies the starting position of the search within the target string; if ''start'' is not provided, the search defaults to 1, which represents the first character position. The optional parameter, ''count'', is a numeric expression that specifies the number of substitutions to perform; if count is not provided -1 is used and all possible substitutions are made. The optional parameter, ''compare'', is used to specify the type of search performed. See the Filter function for values.
Replace returns a string which has had one substring replaced by another a specified number of times. The required parameter, ''target'', is a string expression containing the substring to replace. The required parameter, ''find'', is the string expression to be replaced. The required parameter, ''source'', is the string expression used as the replacement. The optional parameter, ''start'', is a numeric expression that specifies the starting position of the search within the target string; if ''start'' is not provided, the search defaults to 1, which represents the first character position. The optional parameter, ''count'', is a numeric expression that specifies the number of substitutions to perform; if count is not provided -1 is used and all possible substitutions are made. The optional parameter, ''compare'', is used to specify the type of search performed. See the Filter function for values.


'''Example'''
== Example ==


<pre>
<pre>
REM REPLACE Example
Rem Replace Example
'REPLACE performs string substitutions
'Replace performs string substitutions
DIM Message, Ride
Dim Message, Ride
Message = "Good morning, class."
Message = "Good morning, class."
PRINT Message
Print Message
Message = REPLACE(Message, "morning", _
Message = Replace(Message, "morning", _
   "afternoon")
   "afternoon")
PRINT Message
Print Message
Ride = "big Al's big boat ride"
Ride = "big Al's big boat ride"
Ride = REPLACE(Ride, "big", "Big", 1, 1)
Ride = Replace(Ride, "big", "Big", 1, 1)
PRINT Ride
Print Ride
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
Line 28: Line 28:
Big Al's big boat ride
Big Al's big boat ride
</pre>
</pre>
[[Category:Language Reference]]

Revision as of 02:53, 17 August 2012

Replace(target, find, source[, start[, count[, compare]]])

Description

Replace returns a string which has had one substring replaced by another a specified number of times. The required parameter, target, is a string expression containing the substring to replace. The required parameter, find, is the string expression to be replaced. The required parameter, source, is the string expression used as the replacement. The optional parameter, start, is a numeric expression that specifies the starting position of the search within the target string; if start is not provided, the search defaults to 1, which represents the first character position. The optional parameter, count, is a numeric expression that specifies the number of substitutions to perform; if count is not provided -1 is used and all possible substitutions are made. The optional parameter, compare, is used to specify the type of search performed. See the Filter function for values.

Example

Rem Replace Example
'Replace performs string substitutions
Dim Message, Ride
Message = "Good morning, class."
Print Message
Message = Replace(Message, "morning", _
  "afternoon")
Print Message
Ride = "big Al's big boat ride"
Ride = Replace(Ride, "big", "Big", 1, 1)
Print Ride

Output

Good morning, class.
Good afternoon, class.
Big Al's big boat ride