Sunday, February 9, 2014

Re: matchstr() ^ and $ wrong for multi-line text?

Oh yeah, huh:
  Don't forget that "^" will only match at the first character of the String and 
  "$" at the last character of the string.  They don't match after or before a   
  "\n".

Guess I just lost the scavenger hunt…

David


On Sun, Feb 9, 2014 at 2:15 AM, John Beckett <johnb.beckett@gmail.com> wrote:
David Barnett wrote:
> I noticed that matchstr() seems to always interpret ^ as
> start-of-string and $ as end-of-string, even when the string
> is multiple lines. ":help pattern" says they should be
> start-of-line and end-of-line, respectively.
>
> For example
>   :echo matchstr("foo\nbar", '^foo$')
> matches nothing.

:help matchstr() says it's the same as match(), and the help for
that says to see ':help string-match', and that says that "\n"
can be matched with "\n", but (by implication) not by $.

John


--
--
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 a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/eX0WwxcMj8o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
--
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/groups/opt_out.

No comments: