Skip to main content
Skip table of contents

Text functions: Part 2

Overview

Text functions manipulate Text values and return other Text values.

EditDistanceQwerty

Computes a score a text value measuring the similarity of two text values, weighting substitutions of adjacent characters on the QWERTY keyboard as one-half of an error.

Syntax

EditDistanceQwerty( value1, value2 )

The required arguments value1 and value2 may be of any type.

Remarks

Like EditDistance, returns a score in the range 0 to 100 measuring the similarity of value1 and value2. A score of zero means the two values are unrelated. A score of 100 means the two values are identical. Case is ignored in the comparison.

This function first compares the two strings and counts the number of errors in the comparison. Errors include:

  • Substitutions of letters adjacent to one another on a QWERTY keyboard ("John" vs. "Johm") which count as one-half of an error

  • Substitutions of letters not adjacent on a QWERTY keyboard ("John" vs. "Johx")

  • Transpositions ("John" vs. "Jonh")

  • Deletions ("John" vs. "Jon") which count as two errors

The final score is then calculated as follows:

100 – error count * 100 / length of longest value

Example

EditDistanceQwerty( "John Smith", "Jojm Smith" ) returns an EditDistanceQwerty of 90.

FindFirst

Returns an Integer describing the first position of substring in text, or -1 if substring is not found.

Syntax

FindFirst( text, substring )

The FindFirst function syntax has the following arguments:

Part

Description

text

Required. Text string to be searched.

substring

Required. Text string to find.

Remarks

Positions are one-based.

Examples

  • FindFirst( "Acme Software", "Software" ) returns 6.

  • FindFirst( "Acme Software", "Microsoft" ) returns -1.

FindLast

Returns an Integer describing the last position of substring in text, or -1 if substring is not found.

Syntax

FindLast( text, substring )

The FindLast function syntax has the following arguments:

Part

Description

text

Required. Text string to be searched.

substring

Required. Text string to find.

Remarks

Positions are one-based.

Examples

  • FindLast("Acme Software", "Software") returns 6.

  • FindLast("Acme Software", "Microsoft") returns -1.

GetAlpha

Extracts the letters from value and returns them.

Syntax

GetAlpha( value )

The required argument value may be of any type.

Example

GetAlpha( "Ocean's 11." ) returns Oceans.

GetAlphaDigits

Extracts the letters and numbers from value and returns them.

Syntax

GetAlphaDigits( value )

The required argument value may be of any type.

Example

GetAlphaDigits( "Ocean's 11." ) returns Oceans11.

GetDigits

Extracts the numbers from value and returns them.

Syntax

GetDigits( value )

The required argument value may be of any type.

Example

GetDigits( "Ocean's 11." ) returns 11.

GetSymbol

Gets the Nth symbol from value, where symbols are defined as consecutive sequences of letters or numbers, or single punctuation marks

Syntax

GetSymbol( value, position )

The GetSymbol function syntax has the following arguments:

Part

Description

value

Required. May be of any type.

position

Required. Must be a literal Integer.

Remarks

If there is no symbol in the specified position, a blank string is returned.

Examples

  • GetSymbol( "John Q. Smith", 2 ) returns "Q".

  • GetSymbol( "Boulder, Colorado ", 2 ) returns "," (a comma).

GetWord

Gets the Nth word from value, where words are defined as consecutive sequences of letters or numbers.

Syntax

GetWord( value, N )

The GetWord function syntax has the following arguments:

Part

Description

value

Required. May be of any type.

N

Required. Must be a literal Integer. N starts at 1 for the first word, 2 for the second, and so on.

Remarks

If there is no Nth word, a blank string is returned.

Example

GetWord( "John Smith", 2 ) returns "Smith"

GUID

Generates a new Globally Unique ID (GUID or UUID). 

Syntax

GUID( )

See http://en.wikipedia.org/wiki/Guid for more information on GUIDs and UUIDs. On Windows, this uses CreateUuid(). On Linux this uses uuid_generate().

Remarks

It returns a string of hexadecimal digits in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Example

GUID() returns E6E0650F-57E8-4D24-B5BE-933E7F0F0580

HtmlEncode

Replaces problem characters with their equivalent character entity codes. 

Syntax

HtmlEncode(text)

The HtmlEncode function syntax has a single argument:

Part

Description

text

Required. Must be of type Text.

Remarks

The HtmlEncode function replaces characters that would cause problems in HTML document formatting with their equivalent character entity codes. The characters that are replaced are:

Character

Symbol

Replacement

Greater than sign

>

>

Less than sign

<

&lt;

Ampersand

&

&amp;

Double-quote

"

&quot;

Single-quote

'

&#39;

The HtmlEncode function does not escape characters solely because they are not in the ASCII or ISO-Latin1 code pages.

Example

HtmlEncode( "hi<there>all"you&guys" ) returns "hi&lt;there&gt;all&quot;you&amp;guys".

HtmlDecode

Replaces HTML character entity codes with the corresponding symbols. 

Syntax

HtmlDecode(text)

The HtmlDecode function syntax has a single argument:

Part

Description

text

Required. Must be of type Text.

Remarks

The HtmlDecode function replaces all HTML character entity codes, including numeric codes, with their corresponding symbols. The list of character entity codes is defined at http://www.w3.org/TR/html4/sgml/entities.html .

In addition to the entities defined in the HTML4 standard, this function will also decode &apos; which was not defined for HTML4.

Example

HtmlDecode( "hi&#376;&Yuml;&#x178;there" ) returns "hiŸŸŸthere".

IsLike

Returns a Boolean value, which is True if text matches the given pattern, and False otherwise.

Syntax

IsLike( text, pattern )

The IsLike function syntax has the following arguments:

Part

Description

text

Required. Must be of type Text.

pattern

Required. Must be of type Text.

Remarks

The function IsLike is similar to the SQL LIKE operator. See Patterns reference for more information.

Examples

  • IsLike( "one", "One" ) returns False.

  • IsLike ( "one", "_ne" ) returns True.

  • IsLike ( "anyone", "%ne" ) returns True.

IsRepeat

Returns True if text consists of all the same letter, repeated at least count times.

Syntax

IsRepeat( text, count )

Part

Description

text

Required. Must be of type Text.

count

Required. May be a literal integer or an expression.

IsRepeat(text, character, count)

Part

Description

Part

Description

text

Required. Must be of type Text.

character

Required. A single-letter string.

count

Required. May be a literal integer or an expression.

The second form of the function returns True if text consists solely of character repeated at least count times.

Examples

  • IsRepeat("aaaa", 3) returns True.

  • IsRepeat("baaa", 3) returns False.

  • IsRepeat("1112", 3) returns False.

  • IsRepeat("1111", 4) returns True.

  • IsRepeat("999999", "9", 4) returns True.

  • IsRepeat("999998", "9", 4) returns False.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.