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.1k 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.
    • publicstP
      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
        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
          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
            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors