Results 1 to 8 of 8

Thread: String searching

  1. #1

    String searching

    Hello.

    How do I search for a keyword in a string?

    Like...

    variable1 := 'How do I check to see if Voltrox is contained in this string?';

    Then search variable1 to determine if it contains Voltrox.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  2. #2

    String searching

    use function "pos"
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #3

    String searching

    How do I use pos?

    I see substring and wide string when i type it.
    But I don't know how to use it.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  4. #4

    String searching

    Quote Originally Posted by Voltrox
    How do I use pos?

    I see substring and wide string when i type it.
    But I don't know how to use it.
    use delphi help perhaps?!?

    Pos returns the index value of the first character in a specified substring that occurs in a given string.

    Unit

    System

    Category

    string handling routines

    function Pos(Substr: string; S: string): Integer;

    Description

    Pos searches for a substring, Substr, in a string, S. Substr and S are string-type expressions.

    Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos ignores case-insensitive matches. If Substr is not found, Pos returns zero.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #5
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    String searching

    type Pos and pres F1:

    Returns the index value of the first character in a specified substring that occurs in a given string.

    Unit
    System

    Syntax


    [Delphi] function Pos(const substr: string; const str: string): Integer; overload;



    [Delphi] function Pos(const substr: WideString; const str: WideString): Integer; overload;


    Description
    In Delphi, Pos searches for a substring, Substr, in a string, S. Substr and S are string-type expressions.

    Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos is case-sensitive. If Substr is not found, Pos returns zero.

    EDIT: @Delfi, LOL
    NecroSOFT - End of line -

  6. #6

    String searching

    Oh. So how do I get the index that's the end of the string?

    Is there a way to do a thing called IF the string is found in the variable then execute my code?
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  7. #7

    String searching

    well maybe by using simple math?

    increment that returned index from Pos by the length of the string searched....and yes, you can branch your code depending on that...if you're just interested if the string is present, use Pos and check the result <> 0...if it is non-zero, the substring has been found....

  8. #8

    String searching

    Ok. Thank you.

    I'll do that.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •