Community
    • Login

    Плагин расширенного поиска

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 3 Posters 1.9k 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.
    • Pavel SanP
      Pavel San
      last edited by

      Добрый день.
      При работе с поиском и заменой текста регулярно возникают задачи, которые не решает стандартный поиск.
      К примеру:

      1. надо найти текст-1 и от текста-1 найти вверх или вниз вхождение текста-2 и далее заменить текст-1 или текст-2 на текст-3.
      2. надо найти текст-1 и от текста-1 переместиться на заданное количество символов влево или вправо и далее сделать замену начиная с этой позиции

      Выше приведенные поиск и замену, можно сделать рекурсивным на заданную глубину.

      Есть ли плагин в Notepad, который решает такие задачи ?

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Pavel San
        last edited by PeterJones

        @pavel-san

        I used Google translate on your post to get:

        Good afternoon.
        When working with text search and replacement, tasks regularly arise that the standard search does not solve.
        For example:

        1. you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-1 or text-2 with text-3.
        2. you need to find text-1 and move from text-1 to the specified number of characters to the left or right and then make a replacement starting from this position

        The above search and replace can be made recursive to a given depth.

        Is there a plugin in Notepad that solves this problem?

        The forum does ask that you post in English preferably. Since it is you who wants help this would be the polite thing to do.

        So if the translation is correct then it does seem possible to complete the tasks with regular expressions. However without concrete examples it is doubtful you will get any help.

        Read the pinned post at the start of the “Help Wanted” section called “Please Read This Before Posting” on how to provide examples and you may get shown how to do it. The Help Wanted section would be a more accurate area to post in.

        Terry

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

          Hello, @pavel-san, @terry-r and All,

          As @terry-r said, there are a lot of questions concerning your requests !!

          First, when you speak of text-1 do you mean :

          • The word, as in the sentence “This abc text-1 xyz is right, but not abctext-1xyz”

          • The string as in the sentence “This abctext-1xyz is right, as well as abc text-1 xyz”

          Secondly, do you mind about the case of letters in text-1 and/or text-2 ?

          In other words, must the string text-1 have :

          • The exact case text-1

          • Are the Text-1, TEXT-1, text-1 and tExT-1 syntaxes all OK ?

          Idem for text-2 !


          Now, your first statement :

          you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-1 or text-2 with text-3.

          can be slipt into two different goals :

          • (A) you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-1 with text-3

          • (B) you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-2 with text 3

          But, in this case, this could also be expressed as :

          • (A) Change text-1 with text-3, if current file contains, at least, one occurrence of text-2

          • (B) Change text-2 with text-3, if current file contains, at least, one occurrence of text-1


          Case (A) could be achieved with the regex S/R :

          • SEARCH (?s)(?=.*text-2).*?\Ktext-1

          • REPLACE text-3

          • Tick the Wrap-around option

          • Select the Regular expression search mode

          • Click once on the Replace All button


          Case (B) could be achieved with the regex S/R :

          • SEARCH (?s)(?=.*text-1).*?\Ktext-2

          • REPLACE text-3

          • Tick the Wrap-around option

          • Select the Regular expression search mode

          • Click once on the Replace All button


          Finally, your second statement is :

          You have to find text-1, and then move from the text-1 to the left or to the right by a given number of characters, and then replace it starting from this position

          Many questions !

          • Do you want to find all occurrences of text-1 or a specific one ?

          • What you want to replace ( an exact number of chars, the next word, an exact string or even some text splited on several lines ? )

          Anyway, here is a first idea :

          • To get the zero-length position, after text-1 and N characters on the right, use the search regex :

          (?-s)text-1.{N}\K

          • To get the zero-length position, before text-1 and N characters on the left, use the search regex :

          (?-s)\K(?=.{N}text-1)

          See you later,

          Best Regards,

          guy038

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