-
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-
-
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.