SitePoint Sponsor

User Tag List

Results 1 to 1 of 1

Thread: Regex Query

  1. #1
    SitePoint Addict
    Join Date
    Apr 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Regex Query

    Hello !

    Let there is a string :
    string name = "a1,b1,\"c,1\",d1";

    Now I use the following code to replace the comma between " " by a .


    int firstIndx = 0, scndIndx = 0;
    string cutstr ;
    firstIndx = name.IndexOf("\"");
    if (firstIndx >= 0)
    {
    scndIndx = name.IndexOf("\"", firstIndx + 1);
    cutstr = name.Substring(firstIndx, scndIndx - firstIndx + 1);

    name = name.Remove(firstIndx, scndIndx - firstIndx + 1);

    //cutstr = cutstr.Replace("\"", "");
    cutstr = cutstr.Replace(",", "");

    name = name.Insert(firstIndx, cutstr);
    }
    Now if I want to do the same using regular expression, what should I do ?

    Thank you.
    Last edited by sovan; Aug 2, 2007 at 01:18.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •