Tuesday, October 7, 2014

Re: Regular Expressions: How to restrict match extension to the first occurrence?

Dear Christian and Al,

thank you very much for your help.

2014-10-07 13:40 GMT+02:00 Christian Brabandt <cblists@256bit.org>:
> Asis,
> Again, please, do not top poste.

I am sorry. Won't happen again.

> It is general list consensus to
> reply below the quoted text, quoting for now repaired manually
>
>> 2014-10-07 13:12, Asis Hallab:
>> as requested I explain my test of the suggested solutions.
>>
>> I tried three regular expressions and used
>> :set hlsearch
>> to see the matched region.
>>
>> The original full line is
>> glm::something lmg::else
>>
>> /\<.\{-}::
>> as well as
>> /\<..\{-}::
>> and
>> /\<.\{-1,}::
>> all matched, and highlighted,
>> glm::something lmg::
>>
>> The only thing after starting vim -U NONE -u NONE was to
>> :set nocompatible
>> and
>> :set hlsearch
>>
>> This result could be obtained on vim 7.4 (MacVim) and vim 7.3 (debian
>> wheezy).
>
>
> Yes I expected something like this. What you see, is actually two
> matches. Like I said before, your pattern just matches twice. Here is
> the part of my previous mail, which I quote again:
>
> ,----
> | My guess is, that you used something like /\<.\{-}::
> | which does what you want, but matches twice, e.g.
> |
> | mlg::some::else
> | ^^^^^^ the second match here
> | ^^^^^ the first match here
> `----
>
> You won't see a difference with :set hls but when you use 'n' to jump
> to each start of the matching region, you will notice easily.

That actually was the case. Thanks again.

>
>
> Best,
> Christian
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> --- You received this message because you are subscribed to the Google
> Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Cheers!

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment