Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts

    Regular Expression

    I am splitting a string by commas

    pattern = /, /

    ,space

    now that gets me around the dollar sign...

    $239,950, 2111, Ganton Green, No. 212, 2, 2/0, Colonial 9/29 /2003, 21163, HOWARD CO.

    but I also want to ignore the part in bold

    right now it is splitting it as

    $239,950
    2111
    Ganton Green
    No. 212
    2
    2/0
    Colonial
    9/29
    2003
    21163
    HOWARD CO.

    but I want it to be like

    $239,950
    2111
    Ganton Green, No. 212
    2
    2/0
    Colonial
    9/29
    2003
    21163
    HOWARD CO.

    I been playing around with it, but can not get it to work...

    Thanks
    Eric

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Why not use a different separator that would not come up in the data? Like, say, a pipe

    $239,950|2111|Ganton Green, No. 212|2|2/0|Colonial 9/29 /2003|21163|HOWARD CO.

    or better, use \n
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    if he hasn't got control over the input format, then that won't work. since he's not doing it that way, i'm gonna guess that he hasn't got any control over it. ; )

    using /, (?!No\.)/ as your separator pattern should do it, but that assumes that No. will consistantly follow that comma.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    I have no control this information come from a text file that is generated by another service. The file is a bunch of junk with no formatting. I got it all the way down to this and thanks to joh6nn it works.
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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