REGEX_MATCH()

Syntax

Result_Flag as L = REGEX_MATCH( Text as C, Search_Expresssion as C [, Options as C ] )

Argument

Description

Result_Flag

.T. (TRUE) if the Expression matched the Text ; otherwise .F. (FALSE).

Text

The character string to examine. The parentheses characters " ( " and " ) " have special meaning. If present, they enclose a regular expression argument. If you want parentheses characters to be part of the text, you must precede them with " \ " characters.

Search_Expresssion

A regular expression that contains a search argument. Refer to Regular Expressions for detailed information.

Options

Optional. Default = "S". Specify which compatibility with a common implementation. tHE flags for Emacs, Awk, Grep, Egrep and Sed conventions allow the pattern to follow the conventions of those utilities (which have slightly different variants regarding what is escaped and what is not escaped).

  • "I" = Ignore case

  • "E" = Follow Emacs conventions

  • "A" = Follow Awk conventions

  • "G" = Follow Grep conventions

  • "EG" = Follow Egrep conventions

  • "S" = Follow Sed conventions

  • "X" = Extended (similar to Awk but no need to escape '' inside of [])

Description

The REGEX_MATCH() function searches Text for a match to Search_Expresssion returns .T. (TRUE) or .F. (FALSE).

The Case Insensitive Flag

The following examples show the effect of the case insensitive flag. Since F is capitalized, the string does not match.

? regex_match("Fred","[a-z]+")

= .F.

Looking for capitals and lowercase explicitly matches.

? regex_match("Fred","[A-Za-z]+")

= .T.

' Or, alternatively, there is a flag for 'case does not matter' - which is

helpful

' if you have a much longer string you are trying to match (i.e. - HTML tags)

? regex_match("Fred","[a-z]+","i")

= .T.

Or, alternatively, there is a flag for 'case does not matter', which is helpful if you have a much longer string you are trying to match (i.e. HTML tags).

? regex_match("Fred","[a-z]+","i")

= .T.

Supported By

Alpha Five Version 6 and Above

Examples

In the first example, there are two arguments: name and ([a-z]+). Note how the first function argument uses parentheses to identify the regular expression argument. The second function argument includes parentheses in the regular expression argument. The square brackets have special meaning, as Does the plus "+" sign. This function asks: Does the string name contain one or more alphabetic characters and only alphabetic characters. The answer is .T. (TRUE).

? regex_match("(name)","\([a-z]+\)")

= .T.

In the second example the two arguments are: (name) and ([a-z]+). Both function arguments include parentheses in the regular expression argument. This function asks: Does the string name contain one or more alphabetic characters and only alphabetic characters. The answer is .F. (FALSE), because parentheses are not alphabetic characters.

? regex_match("\(name\)","\([a-z]+\)")

= .F.

In the third example the two arguments are: [name] and ([a-z]+). This function asks: Does the string [name] contain one or more alphabetic characters and only alphabetic characters. The answer is .F. (FALSE), because square brackets are not alphabetic characters.

? regex_match("[name]","\([a-z]+\)")

= .F.

In the fourth example the two arguments are: 1 and ([a-z]+). This function asks: Does the string 1 contain one or more alphabetic characters and only alphabetic characters. The answer is .F. (FALSE), because numbers are not alphabetic characters.

? regex_match("(1)","\([a-z]+\)")

= .F.

See Also

Regular Expressions, Regular Expressions Functions and Methods, Character Search Functions