Fuzzy Search

Function

Description

uGlob

Compares values case sensitive similar using the UNIX file globbing syntax for its wildcards

uLike

Compares values case insensitive

uMatches

Returns true if a given string matches a regular expression




uGlob

Description

Compares values case sensitive similar using the UNIX file globbing syntax for its wildcards.

Syntax

bool uGlob(pattern, text)

Parameters

string pattern

A string describing a match pattern

string text

A string to investigate

Examples

Example 1

Compare values using UNIX file globbing syntax

uGlob("Mr. *", "Mr. Smith")   // returns 1, indicating
a match
uGlob("Mr. *", "Mrs. Clarke") // returns 0

Globbing rules:

'*' – Matches any sequence of zero or more characters.

'?' – Matches exactly one character. [^...] – Matches one character not in the enclosed list.

[...] – Matches one character from the enclosed list of characters.

With the [...] and [^...] matching, a ']' character can be included in the list by making it the first character after '[' or '^'. A range of characters can be specified using '-'.

Example:

"[a-z]" matches any single lower-case letter. To match a '-', make it the last character in the list.

To match '*' or '?', put them in "[]".

Example: abc[*]xyz, matches "abc*xyz" only.




uLike

Description

Compares values case insensitive.

The uLike function does a pattern matching comparison. The first parameter contains the pattern, the second parameter contains the string to match against the pattern. A percent symbol % in the pattern matches any sequence of zero or more characters in the string. An underscore _ in the pattern matches any single character in the string. Any other character matches itself or it's lower/upper case equivalent (For example, case-insensitive matching).

NoteCurrently uLike only understands upper/lower case for 7-bit Latin characters, hence the uLike is case sensitive for 8-bit ISO8859 characters or UTF-8 characters. For example: uLike('a' ,'A') is 1 uLike('æ' ,'Æ') is 0

Syntax

number uLike(pattern, text)

Parameters

string pattern

A string describing a match pattern

string text

A string to investigate

Examples

Example 1

Compare values using pattern matching

uLike("% happy %", "A happy man.") // returns 1
uLike("% happy %", "A sad man.")   // returns 0



uMatches

Description

Returns true if a given string matches a regular expression.

Syntax

number uMatches(text, regexpr)

Parameters

string text

Text to investigate

string regexpr

Regular expression specification

Examples

Example 1

Check if a string could be interpreted as a floating point number

uMatches("abc","[-+]?[0-9]*\\.?[0-9]*")  // return 0
uMatches("1.23","[-+]?[0-9]*\\.?[0-9]*")  // return 1