CompareStrings

Mon 01 January 2018

Syntax

CompareStrings(new_text, old_text [, content_type [, delimiter]])

Description

Use the CompareStrings function to compare the content of new_text with the content of old_text and return an XML-formatted text string detailing the differences between the two strings.

The XML string indicates the type of change for each line or text segment, based on the delimiter, as shown in the following table:

Notation

Description

None

Both lines are the same

Insert

A line is present in new_text that is not in old_text .

Delete

A line is absent in new_text that is present in old_text .

Change

A change in a line shows as an Insert in new_text and a Delete in old_text .

Parameters

Field or Control

Definition

new_text

Specifies the string that you want to compare with the old version of the string.

old_text

Specifies the old version of the string for comparison.

content_type

Specifies the content type as a literal: text or html. This parameter is optional.

If content_type is html, HTML tags are stripped and are not included in the comparison.

If content_type is not specified, it is set by default to text.

delimiter

An array of string specifying the delimiters to be used to split the content for comparison. This parameter is optional.

If content_type is text and delimiter is not specified, the delimiter is set by default to char(13) (or \n, a carriage return).

If content_type is html and delimiter is not specified, the delimiter array is populated by default with the following values:

["</p>", "</br>", "</h1>", "</h2>", "</h3>", "</h4>", ⇒
"</h5>", "</h6>", "</div>", "</address>", "</pre>", ⇒
"</br>", "</tr>", "</caption>", "</blockquote>"]

Returns

Returns a String in XML format showing the differences between the two input strings.