When testing StrUtils.SearchBuf with the [soWholeWord,soDown] option [soWholeWord,soDown] some unexpected results occurred.
program Project1; Uses SysUtils,StrUtils; function WordFound(aString,searchString: String): Boolean; begin Result := SearchBuf(PChar(aString),Length(aString), 0, 0, searchString, [soWholeWord,soDown]) <> nil; end; Procedure Test(aString,searchString: String); begin WriteLn('"',searchString,'" in "',aString,'"',#9,' : ', WordFound(aString,searchString)); end; begin Test('Delphi','Delphi');
Why are ' Delphi' and ' Delphi ' considered a whole word?
How about reverse search?
function WordFoundRev(aString,searchString: String): Boolean; begin Result := SearchBuf(PChar(aString),Length(aString),Length(aString)-1,0,searchString, [soWholeWord]) <> nil; end; Procedure TestRev(aString,searchString: String); begin WriteLn('"',searchString,'" in "',aString,'"',
I do not understand anything. In addition, the function does not work.
Same results in XE7, XE6 and XE.
Refresh
QC127635 StrUtils.SearchBuf does not work with the [soWholeWord] option