Find block of code delimited by ( ) with multiple lines

Find block of code delimited by ( ) with multiple lines

5
NewbieNewbie
5

    Jan 03, 2006#1

    This should be simple but I've spend the whole day without success.

    Portion of code:
    TABLESPACE reference
    NOLOGGING
    STORAGE ( INITIAL 10M
    NEXT 10M
    PCTINCREASE 0
    )
    BUILD IMMEDIATE
    AS

    All in the world I want to find is:
    STORAGE ( INITIAL 10M
    NEXT 10M
    PCTINCREASE 0
    )

    Then I would replace it with nothing.

    It would be simple if all was in a single line but multiple lines are a problem. Im not sure how to represent this because the clauses and number of lines between both parenthesis are variable. Just want to find the next ')' after the first 'STORAGE ('.

    Thanks in advance!!

    206
    MasterMaster
    206

      Jan 03, 2006#2

      I did a search of the forum and came up with this thread: Searching across multiple lines

      Studying it gave me the clues for this search string:

      ^.*[(].*\p*[)]

      Unix style regex
      Software For Metalworking
      http://closetolerancesoftware.com

      5
      NewbieNewbie
      5

        Jan 03, 2006#3

        mrainey56 wrote:^.*[(].*\p*[)]

        Unix style regex
        Hi! Thanks for your fast response, but it didn't work for me.

        Also tried with ^.*[(](.*\p)*[)] without success.

        Any other idea?
        Forgetting my code I would reduce the problem to find an open '(' and then a closing ')' accross multiple lines.

        206
        MasterMaster
        206

          Jan 03, 2006#4

          It works fine for me, using your text sample. You have Unix mode set, and the Regular Expressions option checked?


          What result do you get?
          Software For Metalworking
          http://closetolerancesoftware.com

          6,686585
          Grand MasterGrand Master
          6,686585

            Jan 04, 2006#5

            In UltraEdit style the regular expression for this is: ([~)]+).

            Although this will work here, it is always very dangerous to use the [~]+ sequence because it is very aggressive. It can only be used in easy situations like your example.

            So I have developed for myself a little macro to delete multi-line blocks.

            This macro named DeleteBlocks deletes all blocks defined by 2 non regular expression strings which can be entered during macro execution from current file position to the end of the file. If someone wants it with regular expression insert the red marked commands.

            Note: Regular expression searches with this method is only possible with UltraEdit style, not with Unix style (^c is not possible in Unix style).

            Properties for macro DeleteBlocks:

            Cancel Dialog = TRUE
            Find with Replace = TRUE
            Hot Key = what you prefer or NONE

            Macro code:

            InsertMode
            ColumnModeOff
            HexOff
            UnixReOff
            Key HOME
            Key HOME
            GetString "Enter first search string (start of block)"
            StartSelect
            Key HOME
            Clipboard 9
            Cut
            EndSelect
            GetString "Enter second search string (end of block)"
            Clipboard 8
            StartSelect
            Key HOME
            Cut
            EndSelect
            Loop
            Clipboard 9
            Find RegExp "^c"
            IfNotFound
            ExitLoop
            EndIf
            Clipboard 8
            Find RegExp Select "^c"
            IfSel
            Delete
            Else
            ExitLoop
            EndIf
            EndLoop
            Clipboard 9
            ClearClipboard
            Clipboard 8
            ClearClipboard
            Clipboard 0
            UnixReOn

            Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style.
            For UltraEdit v11.10c and lower see Advanced - Configuration - Find - Unix style Regular Expressions.
            For UltraEdit v11.20 and higher see Advanced - Configuration - Searching - Unix style Regular Expressions.
            Macro commands UnixReOn/UnixReOff modifies this setting.
            Best regards from an UC/UE/UES for Windows user from Austria

            5
            NewbieNewbie
            5

              Jan 04, 2006#6

              Hey guys thank you a lot, I took a bit of each and finally got a solution.

              mrainey56, I've set Unix Syntax and RegExp but is still not working. Anyway you gave me the basics.
              Mofi your ([~)]+) expression was very helpful too.

              Here it is (at least this works for me):

              STORAGE[ ]*([~(])([A-Z0-9 a-z\p]*)([~)])

              Regards
              ed

              4
              NewbieNewbie
              4

                Matching across newlines

                Sep 18, 2006#7

                Is there something equivalent to the "m" switch in Perl regular expressions that lets the "." character match a newline?

                I'm trying to search and replace the first X number of lines in an HTML file up to a certain string with this:

                <!DOCTYPE[.\n\r]*<!-- InstanceBeginEditable name="Main" -->

                UltraEdit just reports it can't find the string, even though it does exist.

                6,686585
                Grand MasterGrand Master
                6,686585

                  Re: Matching across newlines

                  Sep 18, 2006#8

                  nysus wrote:Is there something equivalent to the "m" switch in Perl regular expressions that lets the "." character match a newline?
                  I have merged your new thread with this existing thread. For an answer see above and adjust your search accordingly.
                  Best regards from an UC/UE/UES for Windows user from Austria

                  4
                  NewbieNewbie
                  4

                    Re: Matching across newlines

                    Sep 18, 2006#9

                    Well, I think the coders of UE need to rewrite their regex engine. While the suggestions above may work, they seem like hacks. Finding matches across lines could best be solved with a regex modifier like Perl.