Navigation:  MCL Reference > Miscellaneous Functions >

Match( )

Print this Topic Previous pageReturn to chapter overviewNext page

The function compares 2 values and if they are equal (.T.) or not (.F.). In Visual FoxPro string comparison using the native operators "=" will be carried out up to the last character of the right hand side. This behaviour can be a trap for most people. You may keep away from this trap by using Match( ).

If there is any of the wildcard characters * and ? in the second argument. The second argument will be treated as a template. "*" matches any number of any characters while "?" matches any single character.

 

Using =:

Compare

Return

Remark

"ABC"="AB"

.T.

In Visual FoxPro string comparison will be carried out up to the last character of the right hand side. Therefore "C" at the left hand side will be ignored

"AB"="ABC"

.F.

In Visual FoxPro string comparison will be carried out up to the last character of the right hand side. Therefore "C" at the right hand side will be taken into account

"AB"="AB"

.T.


 

Using Match( ):

Comparison

Returned Value

Match("ABC","AB")

.F.

Match("AB","ABC")

.F.

Match("AB","AB")

.T.

Match('Ab','ab')

.T.

Match('Ab','ab',1)

.F.

Match('Abc','a*')

.T.

Match('Abc','a*',1)

.F.

Match('Abc','A??')

.T.

Match('Abc','ABC   ')

.T.

Match('Abc','ABC   ',2)

.F.

Match('Abc','Abc   ',3)

.F.

 

Syntax

Match(cValue1,cValue2,nFlag)

Match(cValue1,cTemplate,nFlag)

 

Arguments

cValue1, cValue2

Strings to be compared

nFlag

0 or Omit: Trim character strings and upper and lower case character will be treated as the same

1: Require a exact case match

2: Do not trim character strings

The above values are additive.

 

Returns

Logical

 

 


Page url: http://www.racematenet.com/english/help/index.html?match.htm