Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

some help with a simple RegEX please

  • 21-10-2013 11:23AM
    #1
    Registered Users, Registered Users 2 Posts: 6,342 ✭✭✭


    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,688 Mod ✭✭✭✭stevenmu


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


  • Registered Users, Registered Users 2 Posts: 1,110 ✭✭✭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, Registered Users 2 Posts: 6,342 ✭✭✭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