This is practically as easy as regular expressions get.
^Column\d+$
Question
I want to find texts (using C#), in a string, that starts with the word "Column" and ends any number (for example "100").
In short, I want to find:
Column1
Column100
Column1000
But not to find:
Column_1
_Column1
Column1$
I can't find a way to do it, using regular expressions.
Solution
This is practically as easy as regular expressions get.
^Column\d+$
OTHER TIPS
Another way without Regex :
public string getColumnWithNum(string source)
{
string tmp = source;
if (tmp.StartsWith("Column"))
{
tmp.Replace("Column", "");
UInt32 num
if (UInt32.TryParse(tmp, out num)
{
return source; // matched
}
}
return ""; // not matched
}
this should work.