The mgiString Tag

Tag Behavior

Use the mgiString tag to perform operations on text. (see also mgiInlineString).


Tag Syntax

The mgiString tag has twenty two modes. Each mode has different required and optional parameters. The modes of mgiString are:

  • urlEncode - The urlEncode mode replaces URL reserved characters with encoded versions of those characters.
  • urlDecode - The urlDecode mode replaces encoded URL characters with URL reserved characters.
  • htmlEncode - The htmlEncode mode replaces HTML reserved characters with an encoded version of those characters.
  • htmlDecode - The htmlDecode mode replaces encoded HTML characters with HTML reserved characters.
  • toUpper - The toUpper mode changes the string to all capital letters.
  • toLower - The toLower mode changes the string to all lowercase letters.
  • substring - The substring mode extracts and displays a string of characters.
  • replace - The replace mode finds a string and replaces it with another string.
  • insert - The insert mode inserts a new string of text at a specified location in the string.
  • append - The append mode adds a string of characters to the end of the string.
  • prepend - The prepend mode adds a string of characters to the beginning of the string.
  • padleft - The padLeft mode adds a specified number of characters to the beginning of the string.
  • padright - The padRight mode adds a specified number of characters to the end of the string.
  • trimLeft - The trimLeft mode removes whitespace from the beginning of a string.
  • trimRight - The trimRight mode removes whitespace from the end of a string.
  • trim - The trim function removes whitespace from the beginning and end of a string.
  • getLength - The getLength mode displays the total length of the string.
  • split - The split mode extracts values with a delimiter.
  • regularExpression - The regularExpression mode searches a string for a regular expression pattern.
  • getWordCount - The getWordCount mode displays the total number of words in a string.
  • getCharacterCount - The getCharacterCount mode displays either the total number of characters in a string that are not carriage returns or linefeeds or the total number of times a specified character appears in a string..
  • noOperation - The noOperation mode does not change the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

URLEncode Mode

The urlEncode mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="urlEncode" quoteResult="Yes/No">
String to Encode
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "urlEncode" mode, the mgiString tag replaces all URL reserved characters with an encoded version of the character (e.g., spaces in the URL are replaced with %20 characters).

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

URLDecode Mode

The urlDecode mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="urlDecode" quoteResult="Yes/No">
String to Decode
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "urlDecode" mode, the mgiString tag replaces all encoded characters with URL reserved characters (e.g., %20 characters are replaced with spaces).

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

HTMLEncode Mode

The htmlEncode mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="htmlEncode" quoteResult="Yes/No">
String to Encode
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "htmlEncode" mode, the mgiString tag replaces all HTML reserved characters with an encoded version of the character (e.g., quotation marks are replaced with &quot; characters).

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

HTMLDecode Mode

The htmlDecode mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="htmlDecode" quoteResult="Yes/No">
String to Decode
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "htmlDecode" mode, the mgiString tag replaces all encoded characters with HTML reserved characters (e.g., &quot; characters are replaced with quotation marks).

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

ToUpper Mode

The toUpper mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="toUpper" quoteResult="Yes/No">
String to Change
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "toUpper" mode, the mgiString tag changes the string to all capital letters.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

ToLower Mode

The toLower mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="toLower" quoteResult="Yes/No">
String to Change
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "toLower" mode, the mgiString tag changes the string to all lowercase letters.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Substring Mode

The substring mode of the mgiString tag has a beginning tag with three required parameters and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="substring" beginningIndex="Number" 
length="Number" quoteResult="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "substring" mode, the mgiString tag extracts and displays a string of characters specified by the numeric location of the first character in the string and the length of the string.
  • beginningIndex - The beginningIndex is an integer that indicates the numeric location of the first character to extract and display. The value of the beginningIndex value must be less than the total length of the string. For example, to extract the numeric month from the string "19991025", the beginningIndex would be "5".
  • length - The length is an integer that indicates the length in characters of the string including the beginningIndex. For example, to extract the numeric month from the string "19991025", the beginningIndex would be "5" and the length would be "2".

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Replace Mode

The replace mode of the mgiString tag has a beginning tag with three required parameters and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="replace" stringToReplace="String" 
replacementString="String" quoteResult="Yes/No" 
caseSensitive="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "replace" mode, the mgiString tag finds a string and replaces it with another string.
  • stringToReplace - The stringToReplace is the text that will be found and replaced by the replacement string. To find the escape characters carriage returns, line feeds, and tabs, use the appropriate Escaped String format.
  • replacementString - The replacementString is the text that will replace any string found by the stringToReplace parameter. To find the escape characters carriage returns, line feeds, and tabs, use the appropriate Escaped String format.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.
  • caseSensitive - The caseSensitive parameter specifies whether the stringToReplace value is checked for case-sensitivity. If the caseSensitive parameter value is "Yes", the stringToReplace value is checked for case-sensitivity. If the caseSensitive parameter values is "No", the stringToReplace value is not checked for case-sensitivity. The default value is "No".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Insert Mode

The insert mode of the mgiString tag has a beginning tag with three required parameters and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="insert" stringToInsert="String" 
index="Integer" quoteResult="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "insert" mode, the mgiString tag inserts string of characters at a specified location in the string.
  • stringToInsert - The stringToInsert is the text that is inserted at the location specified in the index parameter. To insert escape characters such as carriage returns, line feeds, and tabs, use the appropriate Escaped String format.
  • index - The index is the integer of the character location where the string is inserted. For example, in the string "abcdef", "c" is at the 3 index position.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Append Mode

The append mode of the mgiString tag has a beginning tag with two required parameters and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="insert" stringToAppend="String" 
quoteResult="Yes/No">
String
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "append" mode, the mgiString tag adds characters to the end of the string.
  • stringToAppend - The stringToAppend is the text that is appended to the end of the string. To insert escape characters such as carriage returns, line feeds, and tabs, use the appropriate Escaped String format.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Prepend Mode

The prepend mode of the mgiString tag has a beginning tag with two required parameters and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="insert" stringToPrePend="String" 
quoteResult="Yes/No">
String
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "prepend" mode, the mgiString tag adds characters to the beginning of the string.
  • stringToPrepend - The stringToPrepend is the text that is prepended to the beginning of the string. To insert escape characters such as carriage returns, line feeds, and tabs, use the appropriate Escaped String format.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

PadLeft Mode

The padLeft mode of the mgiString tag has a beginning tag with one required parameter and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="padLeft" character="Character" 
length="Integer">
String
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "padLeft" mode, the mgiString tag adds a specified number of characters to the beginning of the string.

Optional Parameters:

  • character - The character parameter specifies the type of character that is added to the beginning of the string. To add escape characters such as carriage returns, line feeds, and tabs, use the appropriate Escaped String format. The default character is a blank space.
  • length - The length parameter specifies the number of specified characters to add to the beginning of the string. The default length is "1".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

PadRight Mode

The padRight mode of the mgiString tag has a beginning tag with one required parameter and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="padRight" character="Character" 
length="Integer">
String
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "padRight" mode, the mgiString tag adds a specified number of characters to the end of the string.

Optional Parameters:

  • character - The character parameter specifies the type of character that is added to the end of the string. To add escape characters such as carriage returns, line feeds, and tabs, use the appropriate Escaped String format. The default character is a blank space.
  • length - The length parameter specifies the number of specified characters to add to the end of the string. The default length is "1".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

TrimLeft Mode

The trimLeft mode of the mgiString tag has a beginning tag with one required parameter and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="trimLeft" quoteResult="Yes/No" 
character="Character">
String to Trim
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "trimLeft" mode, the mgiString tag removes all whitespace (including spaces, tabs and returns) from the beginning of a string.

Optional Parameters:

  • character - The character to be trimmed.
  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

TrimRight Mode

The trimRight mode of the mgiString tag has a beginning tag with one required parameter and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="trimRight" quoteResult="Yes/No" 
character="Character">
String to Trim
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "trimRight" mode, the mgiString tag removes all whitespace (including spaces, tabs and returns) from the end of a string.

Optional Parameters:

  • character - The character to be trimmed.
  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Trim Mode

The trim mode of the mgiString tag has a beginning tag with one required parameter and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="trim" quoteResult="Yes/No" 
character="Character">
String to Trim
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "trim" mode, the mgiString tag removes all whitespace (including spaces, tabs and returns) from the beginning and end of a string.

Optional Parameters:

  • character - The character to be trimmed.
  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

GetLength Mode

The getLength mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="getLength" quoteResult="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "getLength" mode, the mgiString tag displays the total length of the string.

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

Split Mode

The split mode of the mgiString tag has a beginning tag with three required parameters and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="split" delimiter="Character" 
index="Integer" quoteResult="Yes/No" 
caseSensitive="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "split" mode, the mgiString tag extracts values with a delimiter.
  • delimiter - The delimiter is the character that separates each part of the string. To specify escape characters such as carriage returns, line feeds, and tabs as delimiters use the appropriate Escaped String format.
  • index - The index is the number of the value to extract. For example, in the following comma-delimited list, an index of "2" will extract the second value of "Smith".
Bob,Smith,919-225-6329,919-225-6330

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.
  • caseSensitive - The caseSensitive parameter specifies whether the delimiter value is checked for case-sensitivity. If the caseSensitive parameter value is "Yes", the delimiter value is checked for case-sensitivity. If the caseSensitive parameter values is "No", the delimiter value is not checked for case-sensitivity. The default value is "No".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

RegularExpression Mode

The regularExpression mode of the mgiString tag has a beginning tag with three required parameters and two optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="regularExpression" regularExpression="RE Value" 
beginningIndex="Integer" quoteResult="Yes/No" 
resultVariableName="Name">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "regularExpression" mode, the mgiString tag searches a string for a regular expression pattern.
  • regularExpression - The regularExpression is the regular expression pattern to search for in the string. Create a regular expression pattern using regular expression symbols.
  • beginningIndex - The beginningindex is an integer that indicates the numeric location in the string to begin searching. The value of the beginningIndex value must be less than the total length of the string. For example, a beginningIndex of "5" would start searching at the "e" in the string "abcdefghij".

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.
  • resultVariableName - The resultVariableName is the name prepended to result variables that contain information about the search. You may choose any name for the result variable prefix. To display result variables use the mgiGet tag. In the following list of available result variables, the resultVariableName prefix is "resultvar". For example, if your resultVariableName is "Email", then the page variable that contains the length of the full match would be named "Email_0_length". Result variables are created and available anywhere on the page after the mgiInlineString tag. The pound signs (#) represent the regular expression subgroup number (from 1 to 9). Zero (0) is the main subgroup that is matched. (Use the mgiGet tag to display variable information.)
    • resultvar - The full match returned by the regular expression.
    • resultvar_0_index - The beginning index of the full match.
    • resultvar_0_length - The length of the full match.
    • resultvar_# - The # subgroup of the match. # can be 1 through 9.
    • resultvar_#_index - The beginning index of the # subgroup match.
    • resultvar_#_length - The length of the # subgroup match.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

GetWordCount Mode

The getWordCount mode of the mgiString tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. The tag form is:

<mgiString mode="getWordCount" quoteResult="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "getWordCount" mode, the mgiString tag displays the total number of words in a string

Optional Parameters:

  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

GetCharacterCount Mode

The getCharacterCount mode of the mgiString tag has a beginning tag with one required parameter and three optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="getCharacterCount" character="Character" 
quoteResult="Yes/No" caseSensitive="Yes/No">
String to Search
</mgiString>

Required Parameter:

  • mode - The mode is the function that the mgiString tag performs. In "getCharacterCount" mode, the mgiString tag displays the total number of characters in a string that are not carriage returns or linefeeds.

Optional Parameters:

  • character - The character or set of characters to be counted.
  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.
  • caseSensitive - The caseSensitive parameter specifies whether the character value is checked for case-sensitivity. If the caseSensitive parameter value is "Yes", the character value is checked for case-sensitivity. If the caseSensitive parameter values is "No", the character value is not checked for case-sensitivity. The default value is "No".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage

NoOperation Mode

The noOperation mode of the mgiString tag has a beginning tag with no required parameters and two optional parameters, a body, and an ending tag. The tag form is:

<mgiString mode="noOperation" quoteResult="Yes/No">
String
</mgiString>

Required Parameter:

  • None.

Optional Parameters:

  • mode - The mode is the function that the mgiString tag performs. In "noOperation" mode, the mgiString tag does not change the string. The noOperation function can be used in conjunction with the quoteResult parameter to only enter quote marks around the string.
  • quoteResult - The quoteResult parameter determines if the processed string is wrapped in quotes. If the quoteResult parameter value is "Yes", then quote marks are added to the beginning and end of the string. If the quoteResult parameter value is "No", then the quote marks are not added to the string.

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage


Example Usage and Output

HTMLEncode Mode

<mgiString mode="htmlEncode">
<mgiPostArgument name="NewsStory">
</mgiString>

In this example, a news story from a form submission is HTML encoded for display on a page.

Split Mode

<mgiString mode="split" delimiter="," index="3">
blue,orange,green,purple,red
</mgiString>

In this example, the third value in a comma-delimited list of values is displayed. The third value from the list in this example is "green".

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage


Suggested Usage

  • Form Processing
  • Dynamic Content

Return to the mgiString Mode Menu | Examples and Output | Suggested Usage


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]