1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

notepad++ - How to delete everything before and after ,

Discussion in 'Programming' started by haliloo22, Feb 12, 2014.

  1. #1
    hello,

    i want only to have the domains. i want to delete all those before and after ,

    390796,domain1.com,1,0,0,false
    390796,43domain2.org,2,0,0,false
    167854,domain3.com,0,1,0,false
    167854,5domain4.com,0,1,0,false

    so i want it like:

    domain1.com
    43domain2.org
    domain3.com
    5domain4.com

    hope somebody know how to do this in notepad++

    thnx
     
    Solved! View solution.
    haliloo22, Feb 12, 2014 IP
  2. #2
    Use regular expression search mode. Replace:

    [0-9]+,
    with nothing (empty)

    and then replace:
    ,.*
    with nothing (empty)
     
    ThePHPMaster, Feb 12, 2014 IP
    Avener likes this.
  3. haliloo22

    haliloo22 Member

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    thnx mate, your my hero
     
    haliloo22, Feb 12, 2014 IP
  4. Iconiplex

    Iconiplex Member

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    43
    #4
    Why wouldn't you use a more straightforward solution like making it a CSV (if it's not already), opening it in Excel, and deleting all the columns you don't want? You could even have a PHP script that takes a comma-delimited file input, breaks it into rows and columns, and then set it to delete everything except the domain column and subsequently output the result as a TXT/CSV file. Much better than regex that you would need to update should your data structure ever change even the slightest bit.
     
    Iconiplex, Feb 12, 2014 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    You'd still need to update the PHP-file, should the data-structure change, unless you code some function to look for a domain-name-structure. And loading it in Excel every time this is needed also seems a bit excessive when two VERY simple regex'es in the editor of choice works wonders.
     
    PoPSiCLe, Feb 12, 2014 IP
  6. Iconiplex

    Iconiplex Member

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    43
    #6
    Not true even in the slightest. You merely have the PHP file output your column options, select which columns you want, and output those columns. Never would need to update the file given you use proper comma delimitation standards.

    As for your latter argument, in regard to the PHP option, his file is already in a comma-delimited format. Even if it's just a .txt file, you can simply rename it to a .csv, upload it to the script, have a simple GUI to select your options, and have the output instantly downloaded.

    Or you can rename it to a .csv, open in Excel, then delete the extra columns. This would take literally ten seconds no matter how much data there is or what the data structure is, as opposed to opening in Notepad++, performing the search/replace multiple times (taking into account the lag if there are numerous rows or a large amount of data), and manually verify that all data was formatted properly (which should always be done in manual data manipulation).

    The output .csv file will still be editable in Notepad++, but you won't have to repeat the search/replace process multiple times, especially given that the data structure could easily change and he would then need to come back here to ask for new regex, when that could be foreseen and avoided.
     
    Last edited: Feb 13, 2014
    Iconiplex, Feb 13, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    You wouldn't need to do the search/replace multiple times, at least not as long as the input was as the OP posted. Two "replace all" would do. (Okay, granted that is "multiple times"), but still quite quick.
     
    PoPSiCLe, Feb 14, 2014 IP