Xbasic

WORD_TAGGED_PATTERN Function

Syntax

Formatted_String as C = WORD_TAGGED_PATTERN(C tagged_input,C tagged_output,C String[,C Word_Separator])

Arguments

tagged_input

A formatted string that identifies the tags of the Input_String and the characters that separate the tags. The syntax for the Input_Format string is described below:

tagged_output

A formatted string that identifies the new sequence of the tags of the Input_String and the new characters that separate the tags.

String

A character string.

Word_Separator

Optional. Default = CR-LF. The character string that separates lines in the list.

Description

Perform tagged expression replacement on words in a string.

Discussion

WORD_TAGGED_PATTERN() parses each "word" (or "record") in the input string (into "tags", or "fields") using the format specified by the Input_String string and creates an output result string based on the format specified by Output_Format. The input string is divided into "words" or "records" by the separator character. The default value for the optional separator is CR-LF (i.e. chr(13) + chr(10) ). For example, assume that you have a CR-LF delimited input_string of the form:

Smith:John:Programmer
Jones:Kelly:Designer
King:Chris:Analyst

Assume that you want to transform this string to this string:

John Smith - Programmer
Kelly Jones - Designer
Chris King - Analyst

The following command will transform the string:

word_tagged_pattern("1:2:3", "2 1 - 3", input_string)

For more information on the format for the Input_Format and Output_Format strings, see the TAGGED_PATTERN()functions.

Examples

This script parses a string and creates a modified output string in an address format.

string = "Fred:Smith:123 Main Street:Boston:Ma:02116"
address = word_tagged_pattern("1:2:3:4:5:6", "1 2~3~4,5 6", string)

now convert the "~" to carriage return-line feed.

address = stritran(address, "~", crlf() )
address ->
"Fred Smith
123 Main Street
Boston,Ma 02116"

This script parses a U.S format date (month, day, year) and outputs a European format date (day, month, year).

word_tagged_pattern("1/2/3", "2-1-3", "2/29/00") ? "29-2-00"

See Also