Community
    • Login

    Search & Replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 37 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.
    • Jose RamalhoJ
      Jose Ramalho
      last edited by

      Hi,

      I am trying to replace code within a programme with thousands of lines and have been unsuccessful in all my attempts.

      Here is an example of what I want to do

      In the programme, there is a line with
      INSTRUCTION MY_VARIABLE
      where INSTRUCTION is an instruction (ex: mov, swap, xor, etc) , and therefore a fixed and known text to search for.
      MY_VARIABLE, on the other hand, is a variable, and therefore can be any text.

      Please note that there is a “TAB” separating the two words INSTRUCTION and VARIABLE.

      I intend to replace it with

      INSTRUCTION FIXED_TEXT(MY_VARIABLE),

      i.e., I keep INSTRUCTION, I keep VARIABLE, and I add a fixed text (FIXED_TEXT) before VARIABLE.
      Additionally, VARIABLE will be enclosed in parentheses.

      How can I do this using Notepad++?

      Thanks

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Jose Ramalho
        last edited by PeterJones

        @Jose-Ramalho said in Search & Replace:

        How can I do this using Notepad++?

        Regular Expression mode on the search and replace. But you are way too vague in your verbal descriptions for me to give any details on what the specific regex is.

        Use the </> button, and enter some text that matches the pattern (even if you have to use fake words), and show two sets of data: the data you start with (“before”), and the data you want it converted into (“after”). Give more than one line of example, elsewise we’re likely to misunderstand.

        ----

        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
        • guy038G
          guy038
          last edited by guy038

          Hello, @Jose-Ramalho, @peterjones and All,

          @jose-ramalho, let’s suppose this INPUT text :

          move	$a
          swap	$b, $c
          

          Then :

          • Open the Replace dialog ( Ctrl + H )

          • Uncheck all box options

          • FIND (?-s)^(.+)\t(.+)

          • REPLACE \1 FIXED_TEXT \(\2\)

          • Select the Regular expression search mode

          • Possibly, check the Wrap around option

          • Click on the Replace All button

          => You should get the following OUTPUT text :

          move FIXED_TEXT ($a)
          swap FIXED_TEXT ($b, $c)
          

          This is just my first idea. Obviously, this requires some ajustements. 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