Community
    • Login

    simple wildcard search

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 3.2k 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.
    • Paul MartinezP Offline
      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 Offline
        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 Offline
          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 Online
            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

            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