Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    simple wildcard search

    Help wanted · · · – – – · · ·
    3
    4
    1148
    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 Martinez
      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
      • gerdb42
        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 Martinez 1 Reply Last reply Reply Quote 3
        • Paul Martinez
          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 Kilborn
            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
            Copyright © 2014 NodeBB Forums | Contributors