1
Ah, hmm, then you are in a bit of a pickle. That is much harder.
You could try replacing any {0} (and {1}, {2}) with some RegEx and then trying to match the string you get at run time against that.
For example:
Boolean AreEqual(string template, string text)
{
string regexed = template.Replace("{0}", ".*");
regexed = template.Replace("{1}", ".*");
regexed = template.Replace("{2}", ".*");
Regex regex = new Regex(regexed);
return regex.IsMatch(text);
}
Please note, my RegEx skills are below par. And of course you would want to replace the replacements at the top with something more intelligent.
Cheers, Marjan
Accepted 1
If you have the value(s) of the arguments at runtime as well, then you could do something like:
Boolean Matches(string runTimeFullString, string runTimeArgument)
{
string FromDatabase = "The Cow is {0}";
return runTimeFullString.Equals(string.Format(FromDatabase, runTimeArgument));
}
If that doesn't help, could you please clarify what you are trying to achieve and what pieces of information you have to work with?
0
Hi Marjan, Thanks for your response. Basically i have to compare two strings one from Resource file another from Databse. Ex: In Resource: The cow is {0} In Data Base: The cow is {0} But during run time the Parameter {0} will be filled and it becomes "The cow is white". So comparing The cow is {0} and The cow is White will be marked as difference. And Data base will not have run time parameters. So Basically i need to compare the strings without the Parameter {0}.
0
using String.Compare method.