How to make new lines without deleting



  • I have this text
    “C) What
    D) Who
    35. What’s this ______ English?
    A) –
    B) in
    C) at
    D) on
    36. Champaigne is ______ French drink.
    A) a
    B) the”
    I want the lines with numbers go one line below like
    "C) What
    D) Who

    1. What’s this ______ English?
      A) –
      B) in
      C) at
      D) on

    2. Champaigne is ______ French drink.
      A) a
      B) the"
      When I do with other formulas I lose the numbers. Thanks guys



  • In the first sample text there shouldn’t be blank line. It appears so when I post this site. I couldn’t understand. So set it clear no blank line in the first example but a blank line desired before number and full stop.



  • @Markomarin sez:

    It appears so when I post this site. I couldn’t understand.

    Simplest way to explain how to avoid: Indent with 4 spaces all of the stuff you don’t want this web site to possibly alter.



  • @Scott-Sumner said:

    Indent with 4 spaces
    Thanks. Just another thing I’ve learned.



  • @Markomarin

    Ummmm…so why not remove all possible confusion from your earlier data posting, use your newfound knowledge…and present the exact data you are talking about, instead of saying “oh yea use the earlier data but there is no blank line here but there is one here and blah blah blah…” (paraphrasing, obviously)?



  • I see and I’m trying to do what you’ve said but I got a notification saying “You are only allowed to edit posts for 180 second(s) after posting”:) although I have posted long ago.



  • Maybe I have delete and and post a new one.



  • This post is deleted!


  • @Markomarin

    …only allowed to edit posts for 180 second(s) after posting

    Yes, this happens for everyone…just add a new post, don’t worry about the old one. The 180 seconds is for each individual post, not posts even older than that just because you happened to add a recent new post.



  • The text is like
    “xyzxyz
    1. xyzxyz
    xyzxyz
    2. xyzxyz
    xyzxyz
    3. xyzxyz”
    The desired is like
    "xyzxyz

    1. xyzxyz
    xyzxyz
    
    2. xyzxyz
    xyzxyz
    
    3. xyzxyz"


  • @Markomarin

    Tip: You can edit the text you want to post here in Notepad++, then copy and paste it here. If you used the Markdown Viewer plugin, you should see a close representation to what it will look like when posted.

    Tip: Make sure that what shows up in the preview window is really what you want before clicking on Submit.



  • This post is deleted!


  • Dear Scott Sumner,
    Everything is correct in the preview window, I put 4 spaces before every line including spaces but whenever I post it seems faulty.



  • @Markomarin,

    Regex Issue

    As mentioned in another thread, we linked you to the regex documentation FAQ three months ago, with the expectation that you wanted to learn, and would thus make use of those resources, rather than just continuing to have us do your job / hobby for you.

    In a help forum like this (especially one that’s about an application, not a general regular expression help forum), requests for help are always taken better when you show a willingness to learn, and when you show an effort in your question. When you come every few months, and ask us to do all your regex work for you, we can lose interest in helping you.

    (For all we know, you are being paid for the results of what you’re asking us to do. We are just volunteering. If we think you’re learning, we’ll probably keep helping. If we think you are trying to get free consulting work, you’ll find it harder to get answers.)

    So, for example, after correctly quoting your text: show us regular expression you’ve tried, and explain why what you chose the regex you did (ie, what you think that regular expression is doing), and tell us what is wrong with the results.

    Formatting issues:

    When you say “everything is correct in the preview window”, we are asking you to look in the window on the right. When you indent text by four characters, in the preview window, it will show up in an obvious black box. Does it for you? If not, then not everything is correct in the preview window. Something that Scott might not have made clear: you need a blank line before and after the indented text.

    For example, if I have this exact text:

    \======
    some normal text
    
        Four spaces, then your text, will offset it, and will prevent special `characters` and **blanks** from being deleted
    
    more normal text.
    \======
    

    should look like this in your preview window, and thus in the final posting:

    ======
    some normal text

    Four spaces, then your text, will offset it, and will prevent special `characters` and **blanks** from being deleted
    

    more normal text.
    ======

    For other formatting hints, you may want to study this post for more details.



  • Dear Peter Jones and Scott Sumner,
    Of course I really appreciate your work and help you have given to over the months. Let me state the obvious I am not an expert on these issues. I have been using notepad++ for some months. And if I have offended or prevented from your concentration please accept my apologies.
    I am using (regular exp.)

    ^\d+\.\s 
    \n 
    

    For the text like

    xyzxyz
    11. xyzxyz
    xyzxyz
    22. xyzxyz
    xyzxyz
    

    it becomes

    xyzxyz
    
    xyzxyz
    xyzxyz
    
    xyzxyz
    xyzxyz
    

    However what I want is

    xyzxyz
    
    11. xyzxyz
    xyzxyz
    
    12. xyzxyz
    xyzxyz
    

    I think I could express my intentions. I greatly appreciated your past help and wouldn’t mind being neglected as you don’t have to prepare regex for ordinary computer users. Regards



  • @Markomarin

    So to me, the proper formatting really Really REALLY helps in clarifying the problem. It doesn’t make those willing to help have to think really hard about “just what IS the problem here” or “what IS the real data”, but rather they can think about solutions, which is the thing desired by all but especially the OP!

    And showing what you’ve already tried is great too because it gives something to build upon! So I think we can start with what you have and tweak it slightly. Let’s use something called capturing groups. With them, you can use part of the Find expression in the Replace expression. You capture with parentheses, ( and ).

    So in your case, if we capture like this in the Find expression: ^(\d+\.\s), whatever text matches what is between the parentheses goes into what is called Capture Group #1.

    If we change your Replacement expression, like so: \n\1, wherever we see a \1, the contents captured in the find expression get inserted into the replacement text.

    That all being said…are the better ways to write your find-and-replace expressions for this example? I would say that there are, but at this point it probably isn’t constructive to throw out what you arrived at, but simply better to just alter it slightly.



  • @Scott-Sumner
    That was just the thing I was looking for, that was another thing I learned from this great community, Thanks guys.


Log in to reply