Thread: Filtering a string?

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    7

    Filtering a string?

    ok, i've been trying to make an application that:

    1. user selects a text file through a open file dialog
    2. content of text file is displayed in a textbox
    3. user clicks a button with the caption "filter"
    4. then the program will filter out everything apart from rapidshare.com links

    i've got up to step 3 but i can't seem to figure out how to filter everything apart from rapidshare links from the text box, any help is appreciated, thanks in advanced.

    Regards, Look-

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Use regular expressions:
    Code:
    string Input = "Yatta yolla http://www.rapidshare.com/yango/yema.html yorka http://www.rapidshare.com yinto";
    string Expression = "http://www\\.rapidshare\\.com.*? ";
    System.Text.RegularExpressions.Regex Regex = new System.Text.RegularExpressions.Regex(Expression);
    
    foreach(System.Text.RegularExpressions.Match Match in Regex.Matches(Input))
    {
    	string FullAddress = Input.Substring(Match.Index, Match.Length);
    }
    The above code is relatively simple, may be improved. Like it assumes the address ends with a blankspace.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM