String cannot contain any part of another string .NET 2.0
Posted
by Aaron
on Stack Overflow
See other posts from Stack Overflow
or by Aaron
Published on 2010-04-21T13:11:39Z
Indexed on
2010/04/21
13:23 UTC
Read the original article
Hit count: 290
I'm looking for a simple way to discern if a string contains any part of another string (be that regex, built in function I don't know about, etc...). For Example:
string a = "unicorn";
string b = "cornholio";
string c = "ornament";
string d = "elephant";
if (a <comparison> b)
{
// match found ("corn" from 'unicorn' matched "corn" from 'cornholio')
}
if (a <comparison> c)
{
// match found ("orn" from 'unicorn' matched "orn" from 'ornament')
}
if (a <comparison> d)
{
// this will not match
}
something like if (a.ContainsAnyPartOf(b))
would be too much to hope for.
Also, I only have access to .NET 2.0.
Thanks in advance!
© Stack Overflow or respective owner