Regex question
-
I hace some code which starts:
if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); }
which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please? -
I hace some code which starts:
if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); }
which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please?Everything? Regex pattern patching is not as simple as "*.xxx" for file name: '*' means "repeated zero or more times" and '.' means any character. If you are trying to match the entire text box with a wild card filename, then why not just do:
if (textBox1.Text == "*.csv")
{
...
}since that will work.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
-
I hace some code which starts:
if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); }
which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please?Or something like
if ( textBox1.Text.EndsWith ( ".csv" ) ) ...
But I would likely use a System.IO.FileInfo and check its Extension property.