For which substring of the string1 matches occurred with the string2.
Posted
by Harikrishna
on Stack Overflow
See other posts from Stack Overflow
or by Harikrishna
Published on 2010-04-06T11:25:15Z
Indexed on
2010/04/06
11:43 UTC
Read the original article
Hit count: 149
I want to know that in particular string1 for which substring of the string1 the string2 matches.Like
String str1="Order Number Order Time Trade Number";
String str2="Order Tm";
string regex = Regex.Escape(str2.Replace(@"\ ", @"\s*");
bool isColumnNameMatched = Regex.IsMatch(str1, regex, RegexOptions.IgnoreCase);
I am using regex because "Order Tm" will also matches "Order Time".It gives bool value that matches occurred or not.
But if it str2 is in str1 then I want to know at which position in the str1 the str2 matches. Like str2="Order Tm"
then something like that returns the string which is matched with str2 in the str1.Here str2="Order Tm"
then it should return like in the str1,Order Time is the substring where matches is occurred.
© Stack Overflow or respective owner