How to find all divides ( / ) but not comments (//) ?

How to find all divides ( / ) but not comments (//) ?

dark3phoenix

    May 12, 2005#1

    This might be very simple, but I'm a beginner when it comes to regular expressions.

    I've diligently read the help and the other topics, but I can't figure out how to
    find all divides ( / ) in my C project, but not the //, /*, */
    which may appear all over the project, including on the line which has a valid divide.

    I'm willing to put up with a few mis-finds (such as in-between multiple line /*...*/ comments), but 80K+ results is too much to scan visually.

    Can anyone help, please?

    Thanks

    cr.

    206
    MasterMaster
    206

      May 12, 2005#2

      What I would do is first replace all the //, /*, and */ pairs with characters that are sure to be absent from the text.

      // to @~@
      /* to @#@
      */ to @&@

      or something along those lines


      Then find all the single /'s and do whatever you want with them

      Then reverse your original replaces


      This sounds slow, but really isn't.

      If you'll do it again in the future, put the commands into a macro or two.


      Of course, somebody might come up with a regex to do it all. I hope so. :D
      Software For Metalworking
      http://closetolerancesoftware.com

      6,613548
      Grand MasterGrand Master
      6,613548

        May 13, 2005#3

        Try this regular expression in Ultraedit style: [~/^*^-]/[~/^*]

        It searches for a / with a preceding charachter, which is not a /, * or - (to exclude comments like pre-/post-processing) and a following character, which is not a / or *.
        Best regards from an UC/UE/UES for Windows user from Austria

        dark3phoenix
        dark3phoenix

          May 13, 2005#4

          Thanks for the replies.

          The search and replace would have worked as well, although the Regex solution was what I was searching for.

          It worked great, and I learned quite a bit about how it works - I'll start using Regular Expressions more often to get practice.

          Thanks again,
          cradoias