• Login
Community
  • Login

find a string and move to new line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 2.0k 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.
  • S
    Sudhir0103
    last edited by PeterJones Jun 27, 2024, 7:31 PM Jun 27, 2024, 6:52 PM

    I would like split line into a new line after finding a specific character

    Eg.

    edit "*.pokotalks.com" set type fqdn set fqdn "*.pokotalks.com"
    

    should become like below

    edit "*.pokotalks.com"
    set type fqdn 
    set fqdn "*.pokotalks.com"
    

    —

    moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

    P 1 Reply Last reply Jun 27, 2024, 7:36 PM Reply Quote 0
    • P
      PeterJones @Sudhir0103
      last edited by PeterJones Jun 28, 2024, 12:52 PM Jun 27, 2024, 7:36 PM

      @Sudhir0103 ,

      You don’t say what the “specific character” is, and there is no specific character in your example data. But if what you want is to convert space character followed by set to newline sequence followed by set (but only if set is a whole word, not the start of some other word like setting), an easy way to do that is:

      • FIND WHAT = \x20set\b
        • the \x20 means the space character; if you wanted, you could just type a space as the first character in FIND WHAT, but it’s hard to copy/paste unnoticed space character from the forum, so I use the escape sequence instead
        • the \b is what keeps it matching set but not setting
      • REPLACE WITH = \r\nset
        • \r\n is the windows CRLF line ending.
      • SEARCH MODE = Regular Expression
      • Click REPLACE ALL

      There are other ways to do it, but this one is pretty easy for a regex (regular expression) newbie to understand

      (update: fixed from saying wrong \x32 to right \x20)

      ----

      Useful References

      • Please Read Before Posting
      • Template for Search/Replace Questions
      • Formatting Forum Posts
      • Notepad++ Online User Manual: Searching/Regex
      • FAQ: Where to find other regular expressions (regex) documentation
      1 Reply Last reply Reply Quote 1
      1 out of 2
      • First post
        1/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors