I have a Multiline textbox who I can paste URL's. The URL's will be paste into a string variable. Now I want, that just URL's from a specific domain can pass into the string variable.
For example:
http://domain-1.tld/gfdgfd.php?=2135346432
http://domain-2.tld/fsefes.php?=2145312542
http://domain-1.tld/random/folders/iwadaex.php?=2112313543
http://domain-2.tld/igewex.php?=2135464432
http://domain-1.tld/folder/inwadawx.php?=2135546432
http://domain-2.tld/ihtfhtf.php?=2143534432
I a have a radiobutton with Domain 1
and Domain 2
. If Domain 1
is checked, Only URL's from Domain 1
will be put in the variable, and so on.
I just need to know, how I filter the URL's...
var result = textBox1.Text.Split('\n').Where(x => x.Contains(@"http://" + domain)).ToArray();
在您的评论后编辑:
var str = String.Join(Environment.NewLine, result);
You can get your lines using Lines
property then filter them using Where
method:
var filteredUrls = textBoxName.Lines.Where(x => x.Contains(someValue)).ToArray();
Then if you want to display them together, you can use String.Join
var output = string.Join(Environment.NewLine, filteredUrls);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.