Community
    • Login

    simple wildcard search

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 2.3k 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.
    • Paul MartinezP
      Paul Martinez
      last edited by

      I know this is simple, but I’m stuck.
      I want to find any three characters before “[TW]” in my document. e.g.: abc[TW] or zxq[TW]
      I cant get it to search for three of any character followed by [TW]

      1 Reply Last reply Reply Quote 0
      • gerdb42G
        gerdb42
        last edited by gerdb42

        What you are looking for is called “Regular Expression search”. You will find this as an option in NPP’s search dialog. For further information about Regular Expressions see this FAQ.

        Your search term depends on what you want to do with your search. To simply find your pattern you may try \b\w{3}\\[TW\\] as search expression (don’t forget to select “Regular Expression” in search options). If you want do do something with the part before the [TW] you could use \b\w{3}(?=\\[TW\\]). This will select any three letters followed by [TW]. If you want to do something with the [TW] try (?<=\b\w{3})\\[TW\\]. This will select [TW] only if preceeded by three letters.

        Paul MartinezP 1 Reply Last reply Reply Quote 3
        • Paul MartinezP
          Paul Martinez @gerdb42
          last edited by

          @gerdb42 said in simple wildcard search:

          \b\w{3}[TW]

          Gerdb - thank you very much! This nails the problem, where I have to find a couple hundred of these in 4,000 lines. Much appreciated.

          1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn
            last edited by

            @gerdb42 said in simple wildcard search:

            (?<=\b\w{3})[TW]

            This one may be problematic with N++ because it starts off with a lookbehind.
            Due to the nature of the way N++ conducts searches, I wouldn’t be confident in this one.
            I’d go with one of the other suggestions.

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