On Fri, Sep 25, 2009 at 11:59 AM, Andy Wokula <anw...@yahoo.de> wrote:
> > Jeremy Conlin schrieb: > > On Fri, Sep 25, 2009 at 12:07 AM, Christian Brabandt <cbli...@256bit.org > >wrote: > > > >> On Fri, September 25, 2009 7:43 am, Jeremy Conlin wrote: > >>> I know there are some regex wizards out there, I am in need of your > help. > >>> I have lines in my file that look like one of the following two > >>> > >>> Some text & more text & (some white space) & ... > >>> Some text & more text & (some numbers, :, or -) & ... > >>> > >>> For the life of me I can't get my regular expression to differentiate > >>> between the two. This is what I tried (but it found both lines): > >>> > >>> \_^\(.\{-}\s&.\{-}&\s*\)\(\s\{-}[\d:-]\{1,}\) > >> You are at least missing the paranthesis in your pattern and I believe > >> the \d form is not valid inside []. > > /[[:digit:]:-] or /[0-9:-] will do. > > >> Using the following pattern > >> > >> ^\(.\{-}\s&.\{-}&\s*\)\((\s\{-}[0-9:-]\{1,})\) > >> > >> works, assuming you want to match the following line: > >> Some text & more text & (12349:-) & ... > > It's confusing to require a match for the surrounding parens ... > > >> regards, > >> Christian > >> > > > > That didn't quite work and it's my fault for not giving better examples. > > Here are two lines: > > > > The genealogies & & 1:2--17 & & 3:23--38 & & \\ > > Elisabeth's seclusion & Judaea: Bethlehem & & & 1:24--25 & & \\ > > > > I want my regular expression to find the first line and not the second > > because there is non-whitespace between the second and third ampersand. > > What I'm trying to do is replace "1:2--17" with "\index{1:2--17}" > > > > Is that example more clear? > > > > Thanks, > > Jeremy > > this way? > pattern: > /^\%([^&]*&\)\{2}\s*[0-9:-]\+ > > substitute command (with \zs added in the pattern): > > :%s/^\%([^&]*&\)\{2}\s*\zs[0-9:-]\+/\\index{&}/ > > will not work if "&" somehow occurs escaped as part of an entry. > > -- > Andy Yes this works. Thanks! Now do you mind help me understand what everything means, I don't quite understand everything you did? Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---