Re: Question about using variable with RegEx counter
On Thu, May 11, 2006 at 10:40:20AM -0600, Shaun Cummins wrote: > Thanks for the responses everyone! > > > BTW, do you realize that in your end pattern, ".\+" will match all of > > "STA1" "n" "" "" "" "" "" "" > >and .* will then match nothing? > > The values within the quotes can be any text [\w\d-\.\+]. The 6 value > on the first line tells me how many lines are following. I needed to > use .* in the case where the value is set to zero, otherwise my > example where the number is set to zero doesn't match. I think you missed my point. Everything from the first " on the line to the last one, including all the " characters in between, is matched by ".\+". Maybe this *is* what you want, but it does look odd. > >If that's the case I suspect the only way to do it is to set up > >a separate syntax entry for each possible number, so it would be > > > syntax region Keyword start="^\w\+\s\+1\>" end={pattern for one line} > > syntax region Keyword start="^\w\+\s\+2\>" end={pattern for two lines} > > >and so on. Perhaps "syntax match" would be better, depending on the > >precise requirements. It's bad news if the number can go as high as > >2000 but I can't think of an easier way to do it. > > Thanks Matthew. I thought that might be the only way to do it. > Theoretically the number is unlimited, but in practice the number is > almost always less than 12. Since I can't use the captured value in > the counter, I think you are right. This probably is the only way to > do it. I think another way to do it would be using nextgroup. That is, after a start line ending in " 6", specify the nextgroup as Line6; Line6 specifies a nextgroup of Line5; Line5 specifies a nextgroup of Line4; and so on. I am not an expert on syntax definitions, so I am not sure what (dis)advantages this method would have. :help :syn-nextgroup HTH --Benji Fisher
Re: Question about using variable with RegEx counter
Thanks for the responses everyone! I do not think I can answer this, and there may not be a way to do what you want, but I want to clarify the question. Is your intention to match the "STALIST 6" with the start pattern and, since it ends in " 6", match the next 6 lines with the end pattern? BTW, do you realize that in your end pattern, ".\+" will match all of "STA1" "n" "" "" "" "" "" "" and .* will then match nothing? The values within the quotes can be any text [\w\d-\.\+]. The 6 value on the first line tells me how many lines are following. I needed to use .* in the case where the value is set to zero, otherwise my example where the number is set to zero doesn't match. On Thu, May 11, 2006 at 10:12:32AM -0400, Benji Fisher wrote: On Wed, May 10, 2006 at 02:53:20PM -0600, Shaun Cummins wrote: > I would like to use a variable within a regular expression counter. I > tried the following, but it gave me a syntax error: > > :syntax region Keyword start="^\w\+\s\+\z(\d\+\)" > end=#\(\s*\(".\+"\|'.\+'\).*\n\)\{\z1\}# [snip] I do not think I can answer this, and there may not be a way to do what you want, but I want to clarify the question. Is your intention to match the "STALIST 6" with the start pattern and, since it ends in " 6", match the next 6 lines with the end pattern? If that's the case I suspect the only way to do it is to set up a separate syntax entry for each possible number, so it would be syntax region Keyword start="^\w\+\s\+1\>" end={pattern for one line} syntax region Keyword start="^\w\+\s\+2\>" end={pattern for two lines} and so on. Perhaps "syntax match" would be better, depending on the precise requirements. It's bad news if the number can go as high as 2000 but I can't think of an easier way to do it. Thanks Matthew. I thought that might be the only way to do it. Theoretically the number is unlimited, but in practice the number is almost always less than 12. Since I can't use the captured value in the counter, I think you are right. This probably is the only way to do it. -Shaun
Re: Question about using variable with RegEx counter
On Wed, May 10, 2006 at 02:53:20PM -0600, Shaun Cummins wrote: :syntax region Keyword start="^\w\+\s\+\z(\d\+\)" end=#\(\s*\(".\+"\|'.\+'\).*\n\)\{\z1\}# How about :syntax region Keyword start="^\w\+\s\+\z(\d\+\)" \ end=#^\s*"[A-Z]*\z1"# ? Yakov
Re: Question about using variable with RegEx counter
On Thu, May 11, 2006 at 10:12:32AM -0400, Benji Fisher wrote: > On Wed, May 10, 2006 at 02:53:20PM -0600, Shaun Cummins wrote: > > I would like to use a variable within a regular expression counter. I > > tried the following, but it gave me a syntax error: > > > > :syntax region Keyword start="^\w\+\s\+\z(\d\+\)" > > end=#\(\s*\(".\+"\|'.\+'\).*\n\)\{\z1\}# [snip] > I do not think I can answer this, and there may not be a way to do > what you want, but I want to clarify the question. Is your intention to > match the "STALIST 6" with the start pattern and, since it ends in " 6", > match the next 6 lines with the end pattern? If that's the case I suspect the only way to do it is to set up a separate syntax entry for each possible number, so it would be syntax region Keyword start="^\w\+\s\+1\>" end={pattern for one line} syntax region Keyword start="^\w\+\s\+2\>" end={pattern for two lines} and so on. Perhaps "syntax match" would be better, depending on the precise requirements. It's bad news if the number can go as high as 2000 but I can't think of an easier way to do it. -- Matthew Winn ([EMAIL PROTECTED])
Re: Question about using variable with RegEx counter
On Wed, May 10, 2006 at 02:53:20PM -0600, Shaun Cummins wrote: > I would like to use a variable within a regular expression counter. I > tried the following, but it gave me a syntax error: > > :syntax region Keyword start="^\w\+\s\+\z(\d\+\)" > end=#\(\s*\(".\+"\|'.\+'\).*\n\)\{\z1\}# > > If I replace \z1 with 1 or some other number it works fine. I also > tried something like \{,20\} but then it will only do a greedy match > on the first line and skip the rest. > > The region I'm trying to match is: > > PRNEXCLUDED 0 > > or > > SERVER 1 '0' > > or > > STALIST 6 > "STA1" "n" "" "" "" "" "" "" > "STA2" "n" "" "" "" "" "" "" > "STA3" "n" "" "" "" "" "" "" > "STA4" "n" "" "" "" "" "" "" > "STA5" "n" "" "" "" "" "" "" > "STA6" "n" "" "" "" "" "" "" > > Any help would be greatly appreciated. > > Thanks, > > Shaun I do not think I can answer this, and there may not be a way to do what you want, but I want to clarify the question. Is your intention to match the "STALIST 6" with the start pattern and, since it ends in " 6", match the next 6 lines with the end pattern? BTW, do you realize that in your end pattern, ".\+" will match all of "STA1" "n" "" "" "" "" "" "" and .* will then match nothing? HTH --Benji Fisher