• Login
Community
  • Login

Searchin with wildcards

Scheduled Pinned Locked Moved General Discussion
search pattern
2 Posts 2 Posters 11.6k 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.
  • F
    Fernando Conti
    last edited by Oct 7, 2017, 12:57 AM

    Hi.

    Well, I dont know if this could be possible , but I’d like to search and replace arguments with anothers using wildcards.

    For example, I’d like to find all the worlds between symbols [] and replace them with others or simply erase them.
    So if my text file have ocurrences like [one] , [two], [three], etc. I’d like to replace all these at the same time with [nothing] or simply search all the worlds that are between [] and erase them including the [] symbols.

    Any idea?

    Thanks in advance and apologize for my english.

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Oct 7, 2017, 7:45 AM Oct 7, 2017, 7:44 AM

      Hi, @fernando-conti,

      Very easy with regular expressions, indeed !

      • Open your file, in Notepad++

      • Move back at the very beginning ( CTRL + Origin )

      • Open the Find / Replace dialog ( Ctrl + H )

      • Check the Regular expression search mode

      • Check, if necessary, the Match case option

      • In the Find what: zone, type the regex \[.+?\]

      • In the Replace with: zone, simply type the text that must replace all the [......] zones or leave it empty if you prefer to delete the [......] zones

      • Click on the Replace All button

      Et voilà,

      Notes :

      • As the symbols [ and ] have special meaning in regular expressions, they have to be escaped, both, to be considered as literal characters

      • The part .+? stands for the smallest range of characters, between the symbols [ and ]


      For instance, given the example text, below :

      This is a [123] test for searching [abc] all the [.......] zones !
      

      The regex :

      SEARCH \[.+?\]

      REPLACE Leave EMPTY

      modifies the text as below :

      This is a  test for searching  all the  zones !
      

      If the regex was \[.+\], it would have select the largest zone between the symbols [ and ], that it to say, the string “[123] test for searching [abc] all the [.......]”, in our example. Certainly not what you’re looking for !

      Best Regards,

      guy038

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