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

50031Re: regex: multiline search limited to blocks

Expand Messages
  • Hari Krishna Dara
    May 10, 2004
      Can anyone please confirm that this is a bug in Vim? Will there be a
      fix?

      Thank you,
      Hari

      On Mon, 3 May 2004 at 12:01pm, Hari Krishna Dara wrote:

      >
      > On Mon, 3 May 2004 at 1:29pm, gumnos (Tim Chase) wrote:
      >
      > > > Unfortunately, MSSQL doesn't enforce a statement terminator (t-sql),
      > > so
      > > > the best I can do is assume that a statement is one block of lines
      > > > (containing no empty lines), so limit the search to the block. Now can
      > > > anyone help me create a regex for this? I presume I need to somehow
      > > > avoid \_$ appearing right after \_^ (with optional whitespace in
      > > > between), but I can't figureout how to express this.
      > >
      > > Well, one option would be to use grouping operators. I'm not sure if
      > > your SELECT will always be on the line preceeding the FROM line, but you
      > > might have something like
      >
      > Most probably not, the select could be followed by a number of field
      > names one multiple lines.
      >
      > >
      > > /select\_.\{-}\(;\s*\_$\|\_^\s*\_$\)
      > >
      > > If you don't want to include the separator (either the ";" or the blank
      > > line), you can append the "\@=" marker to exclude the delimiter. This
      > > doesn't forgive semi-colons that may appear within strings like
      > >
      > > SELECT * FROM tblFoo WHERE tblFoo.bar = "your;mom"
      > >
      > > But might be able to be modified to include such. Maybe. :)
      > >
      >
      > I definitely would like to specify a blank line as a separator, but how
      > would the regex be? I think I got it (using the clues from your reply), I
      > should use \(\_.\(\_^\s*\_$\)\@!\) as the atom in the place of \_[^;]
      > which I used for oracle. This e.g., allows me to search for all the
      > inserts that have a from clause:
      >
      > /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
      >




      __________________________________
      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