[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vim and regex construct [^...]



s. keeling on 21 May 2005:
> > [\n]   matches \n	    as expected
> 
> What does "\n" mean to you?  Is it the newline character, or a literal
> "n" (sans shell interpretation)?

A newline character.

> > [^\n]  matches \n	    ???
> > [^^M]  doesn't match \n	    ???
> > 
> > OBS.: I got ^M typing Ctrl-V and <Enter>
> > 
> > The results look contradictory. vim's manual states that [^...] should
> > match \n. Therefore, both [^\n] and [^^M] should then match \n.
> > 
> > The manual also says that backslash sequences such as \n cannot be used
> > inside [...], but [\n] matches \n.
> 
> That should tell you something.  "n" == "n"; the "\" is ignored.

Perhaps I wasn't clear: [\n] matches a newline character.

Could this be a bug ?

Regards,
Paulo

OBS.: I was just studying 'Mastering Regular Expressions' and bumped
      into an example to match make-like continuation lines.



Reply to: