Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 447393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:33:57+00:00 2026-05-12T21:33:57+00:00

In Delphi 2009 or later (Unicode), are there any built-in functions or small routines

  • 0

In Delphi 2009 or later (Unicode), are there any built-in functions or small routines written somewhere that will do a reasonably efficient whole word search where you provide the delimiters that define the word, e.g.:

function ContainsWord(Word, Str: string): boolean;

const  { Delim holds the delimiters that are on either side of the word }
  Delim = ' .;,:(){}"/\<>!?[]'#$91#$92#$93#$94'-+*='#$A0#$84;

where:

Word: string;  { is the Unicode string to search for }
Str: string;   { is the Unicode string to be searched }

I only need this to return a true or false value if the “Word” is in the string.

There must be something for this somewhere, because the standard Find Dialog has “Match whole word only” as one of it’s options.

How is this normally (or best) implemented?


Conclusion:

RRUZ’s answer was perfect. The SearchBuf routine was just what I needed. I can even go into the StrUtils routine, extract the code, and modify it to fit my requirements.

I was surprised to find that SearchBuf doesn’t first search for the word and then check for delimiters. Instead it goes through the characters of the string one at a time looking for a delimiter. If it finds one, then it checks for the string and another delimiter. If it doesn’t find it, it then looks for another delimiter. For efficiency’s sake, that’s very smart!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:33:58+00:00Added an answer on May 12, 2026 at 9:33 pm

    You can use the SearchBuf function with the [soWholeWord] option.

    function SearchBuf(Buf: PAnsiChar; BufLen: Integer; SelStart: Integer; SelLength: Integer; SearchString: AnsiString; Options: TStringSearchOptions): PAnsiChar;
    

    See this example

    function ExistWordInString(aString:PWideChar;aSearchString:string;aSearchOptions: TStringSearchOptions): Boolean;
    var
      Size : Integer;
    Begin
          Size:=StrLen(aString);
          Result := SearchBuf(aString, Size, 0, 0, aSearchString, aSearchOptions)<>nil;
    End;
    

    Use it this way

    ExistWordInString('Go Delphi Go','Delphi',[soWholeWord,soDown]);
    

    Bye.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Delphi 2009 I'm finding that any time I use TThread.CurrentThread in an application,
I am using Delphi 2009 and I noticed that there is a macro recorder
Delphi 2009 and above support unicode. I have few legacy pascal source files that
In Delphi 2009, synchronize'd functions that worked fine in Delphi 7 execute with sublime
Using Delphi 2009 on Windows XP to develop desktop application. Is there any way
In Delphi 2009 there is a package, that was installed properly, and works. However
I had some code before I moved to Unicode and Delphi 2009 that appended
Since Indy is now built-into the install process of Delphi 2009... is there a
In Delphi 2009 and Windows API, is there a way to detect that a
This is Delphi 2009, so Unicode applies. I had some code that was loading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.