Community
    • Login

    Searchin with wildcards

    Scheduled Pinned Locked Moved General Discussion
    search pattern
    2 Posts 2 Posters 13.4k Views 1 Watching
    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.
    • Fernando ContiF Offline
      Fernando Conti
      last edited by

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

        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors