Board index » cppbuilder » Converting TStringList to AnsiString and Searching a TStringList for specific text

Converting TStringList to AnsiString and Searching a TStringList for specific text

ok i have a TEdit box that i am using as user input and i need to scan
the text that is sent to the TRishEdit for specific words so how do i
search an ansi string to for specific text multiple times. like if i
typed "Now is the time" how would i search for "Now" and "time". i have
tried to convert the user input to a string list cause i found a find()
function but that gave me all sorts of errors any help on the matter
would be much appreciated.

Jason Bird

 

Re:Converting TStringList to AnsiString and Searching a TStringList for specific text


Quote
> ok i have a TEdit box that i am using as user input and i need to scan
> the text that is sent to the TRishEdit for specific words so how do i
> search an ansi string to for specific text multiple times

Try using AnsiString::Pos.  If the a particular text is not contained in the
AnsiString, Pos returns 0.  For example:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if(Edit1->Text.Pos("Now") != 0)
    {
        ShowMessage("'Now' was found.");
    }
    else
    {
        ShowMessage("'Now' was not found.");
    }

Quote
}

--
Yoto Yotov

C++Builder Developer's Network
http://cbdn.cjb.net/

Quote
"Jason Bird" <jbir...@earthlink.net> wrote in message

news:384199DC.3E430A63@earthlink.net...
Quote
> ok i have a TEdit box that i am using as user input and i need to scan
> the text that is sent to the TRishEdit for specific words so how do i
> search an ansi string to for specific text multiple times. like if i
> typed "Now is the time" how would i search for "Now" and "time". i have
> tried to convert the user input to a string list cause i found a find()
> function but that gave me all sorts of errors any help on the matter
> would be much appreciated.

> Jason Bird

Re:Converting TStringList to AnsiString and Searching a TStringList for specific text


On Sun, 28 Nov 1999 16:08:45 -0500, Jason Bird <jbir...@earthlink.net>
wrote:

Quote
>ok i have a TEdit box that i am using as user input and i need to scan
>the text that is sent to the TRishEdit for specific words so how do i
>search an ansi string to for specific text multiple times. like if i
>typed "Now is the time" how would i search for "Now" and "time". i have
>tried to convert the user input to a string list cause i found a find()
>function but that gave me all sorts of errors any help on the matter
>would be much appreciated.

>Jason Bird

Hi Jason,

    you could try to use "perl compatible regular expression" library.

Search for pcre_exec in online help. I can send you a very little BCB
project that demonstrate the use of some pcre_xxxx functions. Tell
me if I should email you with that project.

Regards

Giuliano

Re:Converting TStringList to AnsiString and Searching a TStringList for specific text


: Jason Bird <jbir...@earthlink.net> wrote:

Quote
>how do i
>search an ansi string to for specific text multiple times. like if i
>typed "Now is the time" how would i search for "Now" and "time".

Try using the Pos method for each substring.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Other Threads