I’m trying to create a parsing system for c#, to block my program from fetching images from “banned” websites that are located in a list. I have tried using bool class, to do a Regex.Replace operation, unfortunately it didn’t work out.
To elaborate on what I exactly would like, this is an example:
I have a List BannedSites = new List { “site” };
if(Bannedsites.Contains(input))
{
Don't go to that site
}
else
{
Go to that site
}
Though the error I mostly get is I have “site” in the list, though if someone does “site ” with a space afterwards it goes to the else statement, since it doesn’t directly exist in the list, or if someone does “site?” and we know a questionmark at the end of the url doesn’t make a difference usually to access the site, so they bypass it again. Is it possible to do something that if the input contains “site”, WITHING the string, for it to not go to the site. Sorry if this is a simple code, though I haven’t been able to figure it out and google didn’t help.
Thanks in advance!
You can use LINQ’s
.Anyto help with that:Remember to use
.ToUpperInvariant()on everything to make it case-insensitive.