Xbasic

TEXTSEARCH Function

Syntax

dim result as L = TEXTSEARCH(C string, C search_pattern)

Arguments

string

The character string to search.

search_pattern

The pattern used to search the string. The search pattern can include the keywords AND, OR, and NOT, as well as wildcard characters * (zero or more characters) and ? (any one character).

Returns

resultLogical

Returns .t. if the search_pattern is found. Otherwise, returns .f..

Description

Search a string for a pattern - uses AND, OR between phrases in pattern, and NOT in front of excludes.

Discussion

The textSearch() function searches a character string for words matching a pattern. The function returns .t. if any words in the string matches the pattern. Characters are compared ignoring case.

If used with an Xdialog form, Alpha Anywhere highlights the words that were found when the data is viewed using a form.

Example

? textsearch("now is the time for all good men", "time AND good")
= .T.

? textsearch("now is the time for all good men", "time AND bad")
= .F.

? textsearch("now is the time for all good men", "im")
= .F.

? textsearch("now is the time for all good men", "*im*")
= .T.

? textsearch("now is the time for all good men", "?now")
= .F.

? textsearch("now is the time for all good men", "*now")
= .T.

See Also