Wednesday, December 23, 2009

Re: Match

Jan-Herbert Damm wrote:
> Hello,
>
> Christian Brabandt wrote on 22.12.09:
>> On Tue, December 22, 2009 10:35 am, epanda wrote:
>>> I detect the first column of a csv file like that.
>>>
>>> ^\([^;]\+\);
>>>
>>>
>>> I would like to search in the match string those which contains
>>> spaces.
>
>> ^\([^; ]*\)\s[^;]*;
>
> Could you explain these regexes? I reckon that
>
> ^\([^;]\+\);
>
> Means: at least once anything but a semicolon at the beginning of a line and
> then a semicolon. (But why the grouping \(...\)?)
>
> But in Christians enhancement ^\([^; ]*\)\s[^;]*; I am confused: i read it as:
>
>
> ^\([^; ]*\) One or more times a semicolon followed by a space

"""
zero or more "anything except a semicolon or space (or newline,
implicitly)" at the beginning of the line
"""

so this is everything before the space-of-interest

> \s[^;]* and followed by another whitespace and anything but a semicolon
> zero or more times
> ; and then a semicolon

yes :)

-tim


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: