Loading ...
Sorry, an error occurred while loading the content.

50065Re: regex: multiline search limited to blocks

Expand Messages
  • Hari Krishna Dara
    May 11, 2004
    • 0 Attachment
      On Tue, 11 May 2004 at 12:34pm, Benji Fisher wrote:

      > On Mon, May 10, 2004 at 05:49:10PM -0700, Hari Krishna Dara wrote:
      > > Can anyone please confirm that this is a bug in Vim? Will there be a
      > > fix?
      > >
      > > Thank you,
      > > Hari
      > >
      > [snip]
      > > > /insert\(\_.\(\_^\s*\_$\)\@!\)\+TOTABLE\(\_.\(\_^\s*\_$\)\@!\)\+from
      > > >
      > > > This would match something like:
      > > >
      > > > insert into TOTABLE (
      > > > FIELD1,
      > > > FIELD2,
      > > > FIELD3,
      > > > FIELD4)
      > > > select
      > > > val1,
      > > > val2,
      > > > val3,
      > > > val4
      > > > from
      > > > FROMTABLE
      > > >
      > > > However, when I used the above regex, Vim had trouble searching for all
      > > > the matches, sequentially. I first composed the regex to match the
      > > > statement that I was interested in, then wanted to find all the
      > > > statements that are similar in the same file. So I went to the start and
      > > > started executing "n" command to see the matches one after the other,
      > > > but figured it never matched the original statement. When I manually
      > > > moved the cursor a couple of lines before the original statement and
      > > > executed "n", it nicely matched, suggesting an issue with the distance
      > > > from the cursor position.
      > > >
      > > > I did a little more research by using search() function instead of /
      > > > command with the same regex. It behaved exactly the same, except that
      > > > this time, I got the following error message instead of just keeping
      > > > quite when there are no matches found.
      > > >
      > > > E363: pattern caused out-of-stack error
      > > >
      > > > Any idea if this is a problem with the regex that I used or a bug in
      > > > Vim?
      > > >
      > > > Thank you,
      > > > Hari
      >
      > I tried the regex you mentioned. Just to be sure, here it is
      > again:
      > insert\(\_.\(\_^\s*\_$\)\@!\)\+TOTABLE\(\_.\(\_^\s*\_$\)\@!\)\+from
      > I copied your snippet to a new buffer, removed the mail quotes ("> > "),
      > and made a few copies, separated by blank lines. When I searched for
      > the pattern, I found all the copies, including the one that began on
      > Line 1. This is with vim 6.3a. Can you give a simple example of a file
      > where there is a problem?
      >
      > I also had no trouble with using search(), but I am not all that
      > surprised that you got an out-of-stack error with a real-life example.
      > That '\_.' followed by '\(...\)\@!', all enclosed in '\(...\)\+' is one
      > mean pattern! Maybe there is a way to do what you want without using a
      > single regex...
      >

      I am not surprised if it worked fine in your simple case, as it did
      match a few instances before failing even in my case. The file is huge
      with about 14,000 lines. If someone is interested in debugging the
      problem, I can probably send it personally after masking a few things in
      it.

      Not using a single regex is a good idea, as I figured I have to write a
      function anyway even for the above regex (I don't think I want to type
      it in everytime), so I will think about the alternatives. Thanks for the
      suggestion.

      Hari




      __________________________________
      Do you Yahoo!?
      Win a $20,000 Career Makeover at Yahoo! HotJobs
      http://hotjobs.sweepstakes.yahoo.com/careermakeover
    • Show all 6 messages in this topic