Click here to Skip to main content
16,012,821 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi developers!
I'm Vishal Sharma.
My problem is I have a csv file that can contain 1 MB data and csv file loads in the dataset and shows in DataGridView, data contains a Regular Expression in multiple columnns or rows; I do not know which columns contain regular expressions, so I want replace mehod work on all the columns or rows in the dataset.
I have a code that contains System.Text.Regex for replace each rows but I do not know how all the rows taken in a parameter.

The code is:
C#
string str = ",";
string mtr = "/";
foreach (DataRow datarow in dataset.Tables[0].Rows)
    {
        datarow[]= regex.replace(str.tostring, mtr.tostring)
    }

The datarow index I want to take all the rows, not a single row and I do not how more rows in my dataset.

please solve this code imediatly
Why? Are you my boss?
Posted
Updated 11-Nov-10 3:00am
v4
Comments
Hiren solanki 11-Nov-10 1:05am    
what is your regex in this case.

1 solution

Mr Vishal try like this,

C#
string str = ",";
string mtr = "/";
foreach (DataRow datarow in dataset.Tables[0].Rows)
 {
   foreach(DataColumn datacol in dataset.Tables[0].Columns)
   {
     datarow[datacol]= regex.Replace(datarow[datacol].ToString(), str.tostring, mtr.tostring);
   }
}


Mark as Answer if it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900