#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Question Basic Regex Needed


    Hi,

    I'm new to regex and facing a problem with a CSV file that maybe could be soved using them.

    We have a lot of files where we expected them to have columns separeted by \ ... but a lot of them are being sent with the traditional csv format, separated by commas and strings inside double quotes ".

    Im using Notepad++ and Id like to replace all commas by \ except for those commas which are inside double quotes "

    Is that possible?

    Best regards

    Joao
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,300
    Rep Power
    7170
    That can't be done with a basic regex, you would be better off writing a script in a normal programming language to do it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0
    if you can use php you can do this by using preg_replace($pattern,$replacement, $data) function. regex pattern would be ([,]+)|".[^"]*?" so preg_replace('%([,]+)|".[^"]*?"%s','\',$data);

IMN logo majestic logo threadwatch logo seochat tools logo