Delphi Regular Expression help

Discussion in 'Programming' started by p2y, Oct 5, 2008.

  1. #1
    Hi,
    I'm working of a project and i need some help.
    I should take specified strings from a text file.

    Example :

    <title="string">

    I don't have much knowladge about regular expressions , I've tried to do this with string functions but i couldn't.

    Do you know a better way ?

    Thanks
    ~Bugra
     
    p2y, Oct 5, 2008 IP
  2. leska

    leska Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    You can try to use next approach. Almost pseudocode:

    int startIndex = searchText.indexOf("<title=\"");

    for (int i=startIndex+2; i< searchText.length; i++) {
    if (searchText[i-2] != "\" and searchText[i-1] == "\"" and searchText == ">") {
    return searchText.substring(startIndex + "<title=\"".length, i);
    }

    }

    Of course you need to add additional validations.
     
    leska, Oct 11, 2008 IP