vimscript – “non-greedy” [](word) regexp problem

consider this sentence (a line in a text file):

 mi chiamo [Giorgio Robino](person) ed abito in [corso Magenta 35/4 a Genova](address)

I want to search (select/extract) the pattern <any chars> inside [<any chars>](<word>).

By example, from text: [Giorgio Robino](person), I want to select Giorgio Robino

And from text:
[corso Magenta 35/4 a Genova](address), I want to select corso Magenta 35/4 a Genova.


I entered these 2 regexp search patterns:

/\[\zs.\{-}\ze\](person)
/\[\zs.\{-}\ze\](address)

But, as you can see in the screenshot, it happens that the second search highlights a single selection, as the span:

mi chiamo [Giorgio Robino](person) ed abito in [corso Magenta 35/4 a Genova](address)
           ^                                                              ^ 
           |                                                              |

Instead I would like to have 2 separated selections:

mi chiamo [Giorgio Robino](person) ed abito in [corso Magenta 35/4 a Genova](address)
           ^            ^                       ^                         ^ 
           | selection1 |                       | selection2              |

So my regexp fails, being “non-greedy”.

May you help me finding the right regexp? Any solution suggested?

BTW, my question is related to the plugin I created:
github.com/solyarisoftware/Highlight.vim

enter image description here

Read more here: Source link