basic.swap
Searches the 'string.expression' for the 'start'-th instance of the 'search.string', then replaces 'search.string' with 'replacement.string' for the next 'occurances' instances. If occurances is not specified, all occurances are replaced. If start is miss
Syntax
swap(string.expression,search.string,replacement.string{,occurances{,start}})
Description
searchs a 'string.expression' for the 'search.string' and then, if at the 'start' occurrence, will replace 'search.string' with 'replacement.string' for 'occurrences' occurrences. If 'start' or 'occurrences' are omitted, they will default to 1 and 0 respectively. An 'occurrence' setting of 0 will replace all occurrences of 'search.string' with 'replacement.string'.
Example
nstring = swap('The new time','new','old')
The assigns the value 'The old time' to nstring.
print swap('---','-','+',2,1)
This will output '-+-'. The 'swap' function will replace
one occurrence of '-' starting at the second occurrence.
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
