Community
    • Login

    Is there any plugin to search specific word within the specific method?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 1.4k Views 2 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.
    • publicstP Offline
      publicst
      last edited by

      Hi,

      I would like to know if there are way to search for any word within all of the specific overridden methods.

      For example, I have countless amount of method override in one file, and I would like to search a method with for loop in it. This file would have many method declared in it but I am only interested in the overridden method that also contains for loop.

      Is there any plugin that supports such a search?

      Below is example.
      If I search for “method” and “for”, search result would return me method 2 and 4 but not 5th one (because it is different method).

      void method() // method 1
      {
      int a = 0;
      }

      void method(int a) // method 2
      {
      for (int i = 0; i < a; i++)
      // do something
      }

      void method(double d) // method 3
      {
      double a = d;
      }

      void method(string s) // method 4
      {
      for (int i = 0; i < s.Length(); i++)
      // do something
      }

      void otherMethod() // method 5
      {
      for (int i = 0; i < 10; i++)
      // do something
      }

      Claudia FrankC 1 Reply Last reply Reply Quote 2
      • Claudia FrankC Offline
        Claudia Frank @publicst
        last edited by

        @publicst

        with a regex like this (?is)void method(?>(?!\}).)*for.*?\} it should be possible.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 3
        • publicstP Offline
          publicst
          last edited by

          Wow that certainly does it!
          Thank you so much! This saves me a lot!

          1 Reply Last reply Reply Quote 1
          • guy038G Offline
            guy038
            last edited by guy038

            Hi, @publicst, @claudia-frank and All,

            A similar and more simple regex could be :

            SEARCH (?s-i)void method[^}]+for.+?\}

            Cheers,

            guy038

            1 Reply Last reply Reply Quote 1

            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