Community
    • Login

    Regex: Select only the line 27 (mark a particular line)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 4 Posters 5.2k 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.
    • Scott SumnerS
      Scott Sumner
      last edited by

      You could use the technique presented here:
      https://notepad-plus-plus.org/community/topic/12291/character-position/4

      1 Reply Last reply Reply Quote 0
      • Vasile CarausV
        Vasile Caraus
        last edited by Vasile Caraus

        The formula below works in sublime text editor. But I don’t know why is not working in notepad++. Maybe guy038 will find the solution for notepad++.

        \A(?:^.*$\n){3}\K^.*$ This regex will select line 4 from text.

        So If I want to select line 6, I will put {5}

        Anyway, can anyone make this regex formula to work also in notepad++ ?

        1 Reply Last reply Reply Quote 0
        • MAPJe71M
          MAPJe71
          last edited by

          Using @guy038’s technique presented in the link pointed to by @scott-sumner e.g. select line 27 in text document: (?-s)(.*\R){26}\K.*\R

          1 Reply Last reply Reply Quote 0
          • Vasile CarausV
            Vasile Caraus
            last edited by

            SUPER ! Thanks.

            \R cause some problem at replace, so is much better \r at final

            (?-s)(.*\R){2}\K.*\r

            1 Reply Last reply Reply Quote 0
            • MAPJe71M
              MAPJe71
              last edited by

              some problem

              What exactly?

              1 Reply Last reply Reply Quote 0
              • Vasile CarausV
                Vasile Caraus
                last edited by

                there is one bug in this formula (?-s)(.*\R){26}\K.*\R or (?ms)(.*\R){26}\K.*\R

                It is not unique. It will selects all the multiple of line I choose. (If I press “Replace All” with something)

                in this case, it selects the 27 row, but also selects 54, 81, 108…etc

                1 Reply Last reply Reply Quote 0
                • MAPJe71M
                  MAPJe71
                  last edited by

                  The answer is in @guy038 post here.

                  Hint: 2 x 27 = 54, 3 x 27 = 81.

                  1 Reply Last reply Reply Quote 0
                  • Vasile CarausV
                    Vasile Caraus
                    last edited by

                    hello MapJe27. I am sorry, I cannot find an answer in that post. There, I see a regex that find a line between columns. But not an unique line, that can be use for Replace All in many documents.

                    maybe you can help me a little bit.

                    1 Reply Last reply Reply Quote 0
                    • MAPJe71M
                      MAPJe71
                      last edited by

                      Notes :
                      Always locate your cursor at the beginning of your file, first

                      @Vasile-Caraus said in Regex: Double your words:

                      If I want to replace one single line in many files

                      It would been a lot easier/faster if you had shared this information from the start in this topic!

                      I can’t say it’s not possible with regular expressions, I just don’t know how. I’d use a script with one of the script plugins (PythonScript, LuaScript).

                      1 Reply Last reply Reply Quote 0
                      • guy038G
                        guy038
                        last edited by

                        Hi Vasile Caraus,

                        Just see my solution, below, in topic about replacing by multiple values of a same line :

                        https://notepad-plus-plus.org/community/topic/12341/regex-double-your-words/9

                        Cheers,

                        guy038

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