delete part of text



  • in reference to my old thread here:
    https://community.notepad-plus-plus.org/topic/18793/multiple-txt-to-one-new-txt
    at post #16, i have try this string on my other new txt but this string delete all!
    i have txt like this:

    .: Allopa Detaruso :.
    =================================
    Lukis: pampetet.marertey@yeto.com:cldfgdfgzo14430
    Pra Stimona: Fru
    =================================
     
    moka:/my-wahsjras.zuk                               379912     2019-08-07T02:52:11+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: capdfgdfnn44rz@gmail.com:1ertrete434
    Pra Stimona: Fru
    =================================
     
    moka:/crypto.zip                                   380547     2019-08-07T02:50:07+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: jadfgdf2@gail.com:mfdgfhg11444357
    Pra Stimona: Fru
    =================================
     
    moka:/wahsjras.zuk                                  379807     2019-08-07T02:58:33+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: lfdhreyan@hofail.com:pipoqfdhghnha
    Pra Stimona: Fru
    =================================
     
    moka:/RECOVER.zip                                  380708     2019-08-07T02:59:03+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: lely-u-kildjss@hotkslail.fr:kedflgdfeove
    Pra Stimona: Fru
    =================================
     
    moka:/[DVD] kalals ''quarter'' in TryrtyOME (Disc 1).mp4 5160256900 2015-11-09T23:17:16+01:00
    moka:/[DVD] mahxgc come Here (TdfhtrrtyrtyM) - Encore.mp4 832324875  2015-11-09T23:20:25+01:00
    moka:/[DVD] mmahshs come Here (YdfgfdgdfgdfgM).mp4 3582747293 2015-11-09T23:50:36+01:00
    moka:/[DVD] oakshdhf come Hfgbere (mashdjskskal) - MC.mp4 902267874  2015-11-09T23:52:03+01:00
    moka:/wahsjras.zuk                                  379957     2019-08-07T03:40:13+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: ddfgdfgi@gail.com:jinyujyukyk304525
    Pra Stimona: Fru
    =================================
     
    moka:/[deanzel] Tenchi Muyo! Ryo-Ohki/             0          2014-10-26T11:56:44+01:00
    moka:/[deanzel] Ndfjhgjtyjykhgi, Imoghkghkgyta Iru!/ 0          2014-12-13T21:08:15+01:00
    moka:/[deanzel] Psycho-Pass [BD 1080p 10bit Dual Audio FLAC-AC3]/ 0          2014-12-23T19:08:45+01:00
    moka:/[deanzel] Steins;Gate/                       0          2015-01-31T06:17:50+01:00
    moka:/[deanzel] Space Dandy - Seagfrrrr [BD 1080p Hi10p Dual Audio FLAC-AC3]/ 0          2015-02-02T20:09:36+01:00
    .: Allopa Detaruso :.
    =================================
    Lukis: pytryrta.martyrly@yaplgo.com:crtytrghmgzo140
    Pra Stimona: Fru
    =================================
     
    moka:/my-wahsjras.zuk                               379912     2019-08-07T02:52:11+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: caznxjsz@gail.com:11238490324 
    Pra Stimona: Fru
    =================================
     
    moka:/crypto.zip                                   380547     2019-08-07T02:50:07+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: jvfvfdv2@gail.com:mdvdfv4443g117
    Pra Stimona: Fru
    =================================
     
    moka:/wahsjras.zuk                                  379807     2019-08-07T02:58:33+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: ldfvdfvd333n@hotmail.com:pdfdggjjytha
    Pra Stimona: Fru
    =================================
     
    moka:/RECOVER.zip                                  380708     2019-08-07T02:59:03+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: lfg55-u-kfhsksss@hotail.fw:kmsjdf773ove
    Pra Stimona: Fru
    =================================
     
    moka:/[Dggf] 5675676575675 ''quarter'' intyjtjtj (Disc 1).mp4 5160256900 2015-11-09T23:17:16+01:00
    moka:/[Dss33] ththytjhytbnb666575 ytjtyjyjngfnvgntry5656y5M) - fhfjjtmp4 832324875  2015-11-09T23:20:25+01:00
    moka:/wahsjras.zuk                                  379957     2019-08-07T03:40:13+02:00
    .: Allopa Detaruso :.
    =================================
    Lukis: deeferferi@gmail.com:jeferook343543525
    Pra Stimona: Fru
    =================================
     
    moka:/[deanzel] Te576uytjgkuyiyui78/             0          2014-10-26T11:56:44+01:00
    
    .: Allopa Detaruso :.
    =================================
    Lukis: pegfdgdgahsj_aryly@yahoo.com:cosjmcneyo109
    Pra Stimona: Fru
    =================================
    

    with reg-ex (?-s)^(?!\h*[\w.\x20]+@).\R?|^.?\x20+
    all text is deleted.
    how to delete all excluding mail:password?
    (in line Lukis: have mail:passw)
    tanxs to everybody for your attention.



  • Hello, @pinuzzu99 and All,

    In fact, the repeated character class of my regex : [\w.\x20]+, contains any character, which may appear before the @ character of the e-mail address

    So, in order that, for instance, the line :

    Lukis: pampetet.marertey@yeto.com:cldfgdfgzo14430
    

    is considered as a line containing a valid e-mail address and, subsequently will not be deleted, you must add the colon character ( : ) to the character class

    In the same way, if you want that the line :

    Lukis: lfg55-u-kfhsksss@hotail.fw:kmsjdf773ove
    

    is considered as a line containing a valid e-mail address and, subsequently will not be deleted, you must
    add the dash character ( - ) to the character class, giving the resulting regex S/R :

    SEARCH (?-s)^(?!\h*[\w.:\x20-]+@).*\R?|^.*?\x20+

    REPLACE Leave EMPTY


    Now, if you suppose than an e-mail address can be preceded with any standard character, but @, simplify the search regex to the syntax, below :

    (?-s)^(?!\h*.+?@).*\R?|^.*?\x20+

    After running one or another regex, you should get, from your example, the expected text :

    pampetet.marertey@yeto.com:cldfgdfgzo14430
    capdfgdfnn44rz@gmail.com:1ertrete434
    jadfgdf2@gail.com:mfdgfhg11444357
    lfdhreyan@hofail.com:pipoqfdhghnha
    lely-u-kildjss@hotkslail.fr:kedflgdfeove
    ddfgdfgi@gail.com:jinyujyukyk304525
    pytryrta.martyrly@yaplgo.com:crtytrghmgzo140
    jvfvfdv2@gail.com:mdvdfv4443g117
    ldfvdfvd333n@hotmail.com:pdfdggjjytha
    lfg55-u-kfhsksss@hotail.fw:kmsjdf773ove
    deeferferi@gmail.com:jeferook343543525
    pegfdgdgahsj_aryly@yahoo.com:cosjmcneyo109
    

    Best Regards,

    guy038



  • Thank you very much for your reply, guy038.
    your string wok fine!

    anyway i didn’t quite understand the difference between:
    (?-s)^(?!\h*[\w.:\x20-]+@).\R?|^.?\x20+
    and
    (?-s)^(?!\h*.+?@).\R?|^.?\x20+

    also first string seems to work well for my purpose…
    what is the difference between the two strings?



  • @pinuzzu99 and All,

    Well. Let’s imagine that you have a line, like below, with a lot of non-alphabetic symbols, which come before the @ symbol :

    Lu&kis: lf#g5%%5-u-kfhsksss@hotail.fw:kmsjdf773ove
    

    Then, in order that the e-mail address are considered as valid ( so that this line will not be deleted entirely ), my first regex syntax should be :

    (?-s)^(?!\h*[\w.:\x20&#%-]+@).*\R?|^.*?\x20+

    Simply because the line above has 6 non-alphabetic characters : & # % - . and space ( \x20 ), before the @ symbol. Note that I put the - char at the end of the character class [....-], because it has a special meaning if located at any other position of that structure !

    Now, if you use the second regex syntax :

    (?-s)^(?!\h*.+?@).*\R?|^.*?\x20+

    This time, we don’t have to bother about possible non-alphabetic characters. Indeed, the part .+? (instead of [\w.:\x20&#%-]+) will select the shortest non-null range of any standard character, till the @ symbol !

    Follow this link to enter the magic world or regexes !

    https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation

    Cheers,

    guy038



  • tanks for your wonderful reply.
    and i have already see your link about reg-ex documentation…
    but there is always little time to do what you want to do!


Log in to reply