What's the most efficient way to pull culture information from a resx filename in C #?
2 answers
Your best bet is to use regex:
string ParseCulture(string input)
{
var r = Regex.new('[\w\d]+\.([\w\-]+)\.resx')
// Match the regular expression pattern against a text string.
Match m = r.Match(input);
if (m.Success)
{
return m.Groups[1];
}
else
{
return "Default";
}
}
This returns a match (with the phrase you are looking for as a match) or no match (which means you should use Default).
+2
a source to share