• Login
Community
  • Login

Want to delete the first paragraph of each line?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 5 Posters 4.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    Ty Ty
    last edited by Jan 25, 2018, 4:24 PM

    I have a file with over 5000 lines. For example: line 1: (34272, xxxxxxx; line 2: (34273, xxxxx; line 3: (34274, xxxxx; line 4: (34275, xxxxx; … now I want to delete: (34272, What?

    And if I want to delete … xxxxx each line like the above example then how do I do? Please help me. Thanks !!!

    C 1 Reply Last reply Jan 25, 2018, 6:31 PM Reply Quote 0
    • C
      Claudia Frank @Ty Ty
      last edited by Jan 25, 2018, 6:31 PM

      @Ty-Ty

      actually I’m not sure if you want to delete the numbers or the xxxxx or both.
      Provide some kind of before and after data, then it might me more clear.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • T
        Ty Ty
        last edited by Jan 26, 2018, 6:37 AM

        OK for example i have 1 file with 5000 lines. Line 1: !2232134, ajeetk1@yahoo.com . Line 2: !2232135, ajeetk28@yahoo.com Line 3: !2232136, ajeetk2@cbemail.ca . Line 4: !2232137, ajeetk_chaudhary @ infosys.com . Remember that the numbers are not the same, you can see it is the number of characters also. I want to delete " !2232134," only keep ajeetk1@yahoo.com , how do?
        If I want to delete the characters at the back of each line eg: Line 1, I want to delete @ yahoo.com , Line 2 : !2232135, ajeetk28 , Line 3 : !2232136, ajeetk2@cbemail.ca and the other lines are similar …
        And vice versa if I want to add after each line a generic character eg: Line 1: !2232134, ajeetk1@ yahoo.com , I want to add the following: !2232134, ajeetk1@yahoo.com email. Line 2 : !2232135, ajeetk28@yahoo.com email . All the lines, I add “email” at the end of each line, how do I?
        My English is bad, I hope you understand. Please help me . Thanks

        S 1 Reply Last reply Jan 26, 2018, 1:27 PM Reply Quote 0
        • S
          Scott Sumner @Ty Ty
          last edited by Jan 26, 2018, 1:27 PM

          @Ty-Ty

          You will have a lot more luck getting people interested in helping if you recreate part of your file here rather than how you described it. Just take part of your file and add four space to the start of each line and then paste it here. Then it will look like this and it will be much more understandable what you are starting with:

          What is Notepad++?
          ******************
          
          Notepad++ is a free (as in "free speech" and also as 
          
          
          Why another source code editor?
          *******************************
          
          The company I worked for used JEXT (another open sour
          

          Of course you have to also describe what you want well, too. MAYBE you did that above, or maybe not (I find that my head hurts when I look at what you composed, so I can’t judge…)

          T 1 Reply Last reply Jan 27, 2018, 11:21 AM Reply Quote 0
          • J
            Jim Dailey
            last edited by Jan 26, 2018, 10:07 PM

            @Ty-Ty

            You want to use regular expression search and replace operations.

            At the end of this post @guy038 points out where you can find information to help you do that.

            1 Reply Last reply Reply Quote 0
            • T
              Ty Ty
              last edited by Jan 27, 2018, 10:37 AM

              Can you guide me how to post yours? How can send your black frame? I need to know that, so I can post the question. And you can understand my question clearly. I am Vietnamese, I am very poor english

              1 Reply Last reply Reply Quote 0
              • T
                Ty Ty @Scott Sumner
                last edited by Jan 27, 2018, 11:21 AM

                  *363780  willtall@gmail.com:xenogears
                  *363781  kaansoulp@gmail.com:kaan1976
                  *363782 angelica.valila@gmail.com:pissis69 
                  *363782 angelica.valila@gmail.com:pissis69
                  *363784 twsnyderman@yahoo.com:sdchbltmvp
                  *363785 shaunamiekley@gmail.com:lfhs929
                  *363786 kynajo@gmail.com:jehovah1
                  *363787 stynrynn@gmail.com:satya96
                  *363788 haleyottley@gmail.com:haley0ttley
                  *363789 pandemonium.jones@gmail.com:odder7471
                  *363790 marielle_koudijs@hotmail.com:Larissa18
                  *363791 robnoice@gmail.com:robtb303
                  *363792 willtall@gmail.com:xenogears
                  *363793 kaansoulp@gmail.com:kaan1976
                  *363794 angelica.valila@gmail.com:pissis69
                  *363795 megsellig@gmail.com:bhyc9999
                  *363796 twsnyderman@yahoo.com:sdchbltmvp
                  *363797 shaunamiekley@gmail.com:lfhs929
                  *363798 kynajo@gmail.com:jehovah1
                  *363799 stynrynn@gmail.com:satya96
                   .......
                

                I have a file as in the number of 5000 lines. My question is: How do I delete the numbers in front of each line for example :

                  willtall@gmail.com:xenogears
                  kaansoulp@gmail.com:kaan1976
                  angelica.valila@gmail.com:pissis69 
                 .....
                

                If you want to delete the back of each line for example :

                 *363780 willtall@gmail.com
                 *363781 kaansoulp@gmail.com
                 *363782 angelica.valila@gmail.com
                  ......
                

                And the last question: If I want to add at the back of each line for example:

                *363780  willtall@gmail.com      Love ( Space is 6 times press Space )
                *363781  kaansoulp@gmail.com      Love
                *363782 angelica.valila@gmail.com      Love       
                ...... 
                

                Seems like these are troublesome questions. I do not use these questions to assess your understanding. Exactly, I’m in a situation like this to solve. Looking forward to receiving your complete reply. Thank you

                C 1 Reply Last reply Jan 27, 2018, 12:59 PM Reply Quote 1
                • C
                  Claudia Frank @Ty Ty
                  last edited by Jan 27, 2018, 12:59 PM

                  @Ty-Ty

                  all solution would need regular expression to be checked and assume that the whole file
                  looks like your example.

                  let me start with the easiest first

                  find what:$
                  replace with: YOUR_TEXT
                  

                  per default $ denotes the end marker of each line

                  next two’s will work until there are only VALID email addresses.
                  It won’t work if there is something like name space @ space domain.name

                  delete everything in front:

                  find what:(.+?)(?=\x20.+?@)
                  replace with:nothing - leave empty
                  

                  ?= is a lookahead which means you are searching for text only if it is
                  followed by a space(\x20) followed by anything (.+) but as less as possible (?) and a @

                  delete everything after the domain name

                  find what:@\<.+?\..+?\>\K.+
                  replace with:nothing - leave empty
                  

                  The last one uses \K which means it only works if you press replace all.
                  Searching for @ next must start a word (\<) followed by anything as less as possible
                  followed by a dot (\.) literally followed by as less as possible but must end with a word.
                  \K ignores that it has matched anything so that the rest (.+) is the only one which gets reported
                  back as the match.

                  I know, not as detailed as guy038’s explanations but hopefully understandable.

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • G
                    guy038
                    last edited by guy038 Jan 27, 2018, 1:47 PM Jan 27, 2018, 1:40 PM

                    Hello, @ty-ty,

                    Seemingly, Ty-Ty, you’re asking for three different points :

                    • A : How to delete some structured data, located at each beginning of line ?

                    • B : How to delete some structured data, located at each end of line ?

                    • C : How to add a string at each end of line ?

                    Just note that the points B and C may be replaced with :

                    • D : How to replace some structured data, at each end of line, by a literal string

                    So, let’s imagine your initial list, opened in Notepad++ :

                      *363780  willtall@gmail.com:xenogears
                      *363781  kaansoulp@gmail.com:kaan1976
                      *363782 angelica.valila@gmail.com:pissis69 
                      *363782 angelica.valila@gmail.com:pissis69
                      *363784 twsnyderman@yahoo.com:sdchbltmvp
                      *363785 shaunamiekley@gmail.com:lfhs929
                      *363786 kynajo@gmail.com:jehovah1
                      *363787 stynrynn@gmail.com:satya96
                      *363788 haleyottley@gmail.com:haley0ttley
                      *363789 pandemonium.jones@gmail.com:odder7471
                      *363790 marielle_koudijs@hotmail.com:Larissa18
                      *363791 robnoice@gmail.com:robtb303
                      *363792 willtall@gmail.com:xenogears
                      *363793 kaansoulp@gmail.com:kaan1976
                      *363794 angelica.valila@gmail.com:pissis69
                      *363795 megsellig@gmail.com:bhyc9999
                      *363796 twsnyderman@yahoo.com:sdchbltmvp
                      *363797 shaunamiekley@gmail.com:lfhs929
                      *363798 kynajo@gmail.com:jehovah1
                      *363799 stynrynn@gmail.com:satya96
                    

                    Obviously, we can deduce that :

                    • The part to delete, at the beginning, of each line ( Case A ) :

                      • Begin by possible space characters, followed by a * symbol

                      • Then followed by some digits ( 6 in our example ) and ends with possible space characters

                    • The part to delete, at the end, of eech line ( Case B ) :

                      • Begin with the unique colon of each line, followed by all the remaining characters of each line

                    So, to achieve point A :

                    • Open the Replace dialog ( Ctrl + H )

                    • Type in the regex ^\x20*\*\d+\x20*, in the Find what: zone

                    • Leave the Replace with: zone EMPTY

                    • Check the Wrap around and Regular expression options

                    • Click on the Replace All button

                    Notes :

                    • The ^ symbol means the beginning of line location

                    • Then, the syntax \x20* represents a string, possibly empty, of space characters

                    • The form \* try to match a literal star character. It must be escaped, due to its special meaning in regexes

                    • And \d+ stands for a non-empty range of consecutive digits

                    • Again, \x20* matches a string, possibly empty, of space characters, before each e-mail address


                    To achieve point B :

                    • Open the Replace dialog ( Ctrl + H )

                    • Type in the regex :.+, in the Find what: zone

                    • Leave the Replace with: zone EMPTY

                    • Check the Wrap around and Regular expression options

                    • Click on the Replace All button

                    Notes :

                    • First, the : matches a literal colon symbol

                    • Then the syntax .+ represents any non-empty range of characters, located after the colon, till the end of each line


                    But, you may combine all these search-replacements, in an unique regex

                    Therefore, to achieve points A and D, at the same time, use the regexes, below :

                    SEARCH ^\x20*\*\d+\x20*|(:.+)

                    REPLACE ?1\x20\x20\x20\x20\x20\x20Love

                    Notes :

                    • The search regex is just an alternative between the two regexes, discussed above

                    • The second regex (:.+) is surrounded by round parentheses, to be stored as group 1

                    • In replacement, the form ?1....... means :

                      • If group 1 exists, just replace the colon and all text, located after, by six space characters, followed by Love

                      • If group 1 does not exist, delete all text, before each e-mail address, as the ELSE part of this conditional replacement is absent !

                    So, after a click on the Replace All button, you should get the text below :

                    willtall@gmail.com      Love
                    kaansoulp@gmail.com      Love
                    angelica.valila@gmail.com      Love
                    angelica.valila@gmail.com      Love
                    twsnyderman@yahoo.com      Love
                    shaunamiekley@gmail.com      Love
                    kynajo@gmail.com      Love
                    stynrynn@gmail.com      Love
                    haleyottley@gmail.com      Love
                    pandemonium.jones@gmail.com      Love
                    marielle_koudijs@hotmail.com      Love
                    robnoice@gmail.com      Love
                    willtall@gmail.com      Love
                    kaansoulp@gmail.com      Love
                    angelica.valila@gmail.com      Love
                    megsellig@gmail.com      Love
                    twsnyderman@yahoo.com      Love
                    shaunamiekley@gmail.com      Love
                    kynajo@gmail.com      Love
                    stynrynn@gmail.com      Love
                    

                    Remark : In the regexes, you may type a single space character, instead of the \x20 syntax ! But, that later form just suppresses any ambiguity !

                    Best Regards,

                    guy038

                    1 Reply Last reply Reply Quote 0
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors