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

2014-10-07 Thread Asis Hallab
Dear Vim experts, consider the following line glm::something mlg::else The goal is to match the words before and including the double colons. Of course /\([a-zA-Z]\+::\) does the job. But the question arose, if /\.\+:: could be restricted to match glm::something and not glm::something

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

2014-10-07 Thread A. S. Budden
Check out \{-} (in :help \{). This is an as few as possible version of *, so you can do: /.\{-}:: If you want to ensure you match something, you can either do: /..\{-}:: or /.\{-1,}:: I tend to use the former as I don't have to think as much... Al On 7 October 2014 11:02, Asis

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

2014-10-07 Thread Asis Hallab
Dear Al, thank you for your effort and reply. Unfortunately none of your three suggestions work, even when tested with vim -U NONE -u NONE. To clarify, in PERL the regular expression that does what I am looking for is achieved by appending ? to the + operator: perl -e 'my $s = glm::something

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

2014-10-07 Thread Christian Brabandt
Am 2014-10-07 12:50, schrieb Asis Hallab: (please do not top poste.) thank you for your effort and reply. Unfortunately none of your three suggestions work, even when tested with vim -U NONE -u NONE. Please show us exactly what you tried, what you expected and what you saw. My guess is,

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

2014-10-07 Thread Asis Hallab
Dear Christian, 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,

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

2014-10-07 Thread A. S. Budden
On 7 October 2014 12:12, Asis Hallab asis.hal...@gmail.com wrote: Dear Christian, as requested I explain my test of the suggested solutions. I tried three regular expressions and used :set hlsearch to see the matched region. This option will highlight ALL matched regions. One of these

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

2014-10-07 Thread Christian Brabandt
Asis, Again, please, do not top poste. 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

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

2014-10-07 Thread Asis Hallab
Dear Christian and Al, thank you very much for your help. 2014-10-07 13:40 GMT+02:00 Christian Brabandt cbli...@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