STRITRAN_SMATCH Function
Syntax
Arguments
- Output_String
The character string produced by the replacement operation.
- character
The character string to search.
- substring_pattern
A pattern of characters to search for. It can include one or more "*" wildcard characters, each of which selects an arbitrary number of characters, and one or more "?" wildcard characters, each of which selects a single character.
- replacement_pattern
A pattern of characters to replace. It can include one or more "*" wildcard characters, each of which selects an arbitrary number of characters, and one or more "?" wildcard characters, each of which selects a single character.In the simple case, there is a one-to-one match between wildcards. However, it is possible to replace the text selected by any wildcard with constant text and/or expressions that generate text.
- reorder
Optional. Default = "1,2,3,...,N". A comma delimited series of numbers that sets the order of the wildcard replacements. If you wished to replace the text found by wildcard 1 in the substring pattern with the text found by wildcard 2 in the substring, you would change the implicit replacement Reorder value of "1,2" to "2,1". You can drop text found by a wildcard by not specifying its number. You can repeat text found by a wildcard by specifying its number multiple times.
Description
Replaces occurrences that match a pattern with another pattern.
Discussion
The STRITRAN_SMATCH() function replaces strings with variable content. It will optionally reorder the content as the replacement is made. STRITRAN_SMATCH() is not case sensitive.
Example
The following examples associate the text to the left of the "=" with the first wildcard and the text to the right of the equal sign with the second wildcard. It replaces the text in the same order that it is found, but adds other text.
string = peter=rabbit charlotte=spider harry=horse %a% ? stritran_smatch(string, "*=*" + crlf() , "*, Species = *" + crlf() ) = peter, Species = rabbit charlotte, Species = spider harry, Species = horse
This example adds the optional reorder argument, but leaves things unchanged.
string = peter=rabbit charlotte=spider harry=horse %a% ? stritran_smatch(string, "*=*" + crlf() , "*, Species = *" + crlf() , "1 2") = peter, Species = rabbit charlotte, Species = spider harry, Species = horse
This example reorders the text.
string = peter=rabbit charlotte=spider harry=horse %a% ? stritran_smatch(string, "*=*" + crlf() , "*, Species = *" + crlf() , "2 1") = rabbit, Species = peter spider, Species = charlotte horse, Species = harry
This example repeats the second text.
string = peter=rabbit charlotte=spider harry=horse %a% ? stritran_smatch(string, "*=*" + crlf() , "*, Species = *" + crlf() , "2 2") = rabbit, Species = rabbit spider, Species = spider horse, Species = horse
See Also