Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

some help with a simple RegEX please

Options
  • 21-10-2013 12:23pm
    #1
    Registered Users Posts: 6,213 ✭✭✭


    I've been googling for half an hour, and this apparently simple situation is eluding me; its been a while since I used regexes.

    I have a CSV file with 3 feilds per line, no quotes:
    1. alnum with an embedded space
    2. a signed float (i.e. - before and . within)
    3 an unsigned float

    I'm using Textpad to try to do a regex search/replace, to take out the commas and insert some xml tags in their place

    I tried
    ^[^\,]*[^\,]*[^\,]*$
    but Textpad says it can't find the regex


Comments

  • Subscribers Posts: 1,911 ✭✭✭Draco


    You can live test your regex using Regexpal. Just paste in a few lines of your CSV and it'll show you exactly what your regex matches as you change it. I find it very useful for debuging regexs.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    http://gskinner.com/RegExr/ is another good one, with a handy reference on the side.


  • Registered Users Posts: 1,109 ✭✭✭Skrynesaver


    bonzodog2 wrote: »
    I've been googling for half an hour, and this apparently simple situation is eluding me; its been a while since I used regexes.

    I have a CSV file with 3 feilds per line, no quotes:
    1. alnum with an embedded space
    2. a signed float (i.e. - before and . within)
    3 an unsigned float

    I'm using Textpad to try to do a regex search/replace, to take out the commas and insert some xml tags in their place

    I tried
    ^[^\,]*[^\,]*[^\,]*$
    but Textpad says it can't find the regex
    Try describing your regex in words, it often illustrates the issue...
    begining of string followed by any number of characters that aren't commas, followed by any number of characters that aren't commas, followed by any number of characters that aren't commas followed by the end of the string....

    Try
    ^[^\,]*,[^\,]*,[^\,]*$
    


  • Registered Users Posts: 6,213 ✭✭✭bonzodog2


    Thanks for your comments and suggestions. I found another way to acheive what I want. I have a sqlite database with latitude/longitude and other data, and wanted to make a KML file to display on Google Earth. I found http://www.convertcsv.com/csv-to-kml.htm very useful.


Advertisement