Such as telephone, search, and, according to the 157 appears all with 157
And not just at the beginning of 157,,,
O the program code
CodePudding user response:
You are clear from where to search? Database? File? Memory?CodePudding user response:
We will write a equipment management procedure, requirements for typing browse for functions such asInformation stored in a file in the directory
CodePudding user response:
Using the LIKEExample:
SELECT * FROM table WHERE columns LIKE (' % % query conditions);
CodePudding user response:
Before write a function that mimic SQL Like action, returned to STR whether can match Like the format string,//case-sensitive, match way: "% % ABC_45" "% __ABC_45__ %
"ABC_45//"% %" "__ABC_45__ ABC_45 % % %"
bool SQLStringLike (AnsiString const & amp; The Format of AnsiString const & amp; STR)
{
If (Format. IsEmpty ())//Format string is empty
Return true;
Else if (the Format=="NULL")//NULL match empty
Return the STR. IsEmpty ();
Char * tryNext=NULL;//only a tryNext, so might be wrong
Char * sf=Format. C_str ();
Char * sp=STR. C_str ();
Char * start;//to compare characters start
Char * end;//to compare characters end
Char * p;
Char x;
While (* sf, & amp; & * sp)
{
If (* sf=='_')//_ match any one character
{
+ + sf;//not identify multibyte characters)
}
Else if (* sf=='%')
{
While (* (sf + 1)=='%') + + sf.//% as a continuous, SQL Server as a mistake
If (* (sf + 1)==0)//end with %
Return true;
The else
{
Start=sf, + 1;
While (* start=='_')/behind/% _
{
+ + start;
+ + sp;
If (* sp==0)
Return false;
}
End=start;
While (* end & amp; & * the end!='%' & amp; & * the end!='_') + + end;
X=* end;
* end=0;
LOOP:
P=STRSTR (sp, start);
If (p)
{
Sp=p + (end - start);
Sf=end;
* end=x;
TryNext=STRSTR (sp, start);//the next match point
continue ;
}
The else
{
* end=x;
Return false;
}
}
}
Else if (* sf!=* sp)
{
If (tryNext)
{
Sp=tryNext;
TryNext=NULL;
Goto LOOP;
}
The else
Return false;
}
The else
+ + sf;
+ + sp;
}
If (sf, [0]=='%' & amp; & Sf, [1]==0)//format string ends with a % for
Return true;
Return (* sf,==* sp);//will be equal to 0
}
CodePudding user response:
AnsiString char * instead of the above functions, not much will change, become C,CodePudding user response:
Looking back, the function is not the Escape of SQL operator [] [^] Escape mask, etc.,CodePudding user response:
Regular expressions can not?CodePudding user response:
The so-called "fuzzy search" is the first to have "fuzzy" to your search