git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Interpret :/<pattern> as a regular expression

From
Jeff King <peff@peff.net>
Date
Jun 13, 2007, 20:00 UTC
Message-ID
<20070613200011.GA17360@coredump.intra.peff.net>
In-Reply-To
<Pine.LNX.4.64.0706131953370.4059@racer.site>
On Wed, Jun 13, 2007 at 07:54:59PM +0100, Johannes Schindelin wrote:
> :-) Since you seem comfortable with regular expressions, maybe you can 
> help me: I am looking for a pattern which matches _any_ character, and one 
> which matches only non-newlines, both with and without REG_NEWLINE. Hmm?

Without REG_NEWLINE, any character is just '.', but I think you are stuck with '[^ ]' for non-newlines, since POSIX makes no provisions for quoting the newline (I just skimmed through POSIX chapter 9, and I didn't see anything useful).

With REG_NEWLINE, non-newlines is of course '.'. Matching both is tricky without using extended regular expressions (where you could just do '.| '). In fact, I have been playing with it for a few minutes and I can't seem to find a good way, since you really want to represent '.' _inside_ a bracketed alternation sequence. But I don't think there's a character class for "everything".

I think this would be much easier with pcre, but ISTR some opposition to that a few months back.

So that's probably not very helpful to you, but at least you have confirmation from one other person that the answer isn't totally obvious. :)

-Peff
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 10 of 14 in “Interpret :/<pattern> as a regular expression”
  1. Interpret :/<pattern> as a regular expressionJohannes Schindelin, Jun 13, 2007
  2. Junio C HamanoJun 13, 2007
  3. Johannes SchindelinJun 13, 2007
  4. Junio C HamanoJun 13, 2007
  5. Johannes SchindelinJun 13, 2007
  6. (unknown)Johannes Schindelin, Jun 13, 2007
  7. Interpret :/<pattern> as a regular expressionJohannes Schindelin, Jun 13, 2007
  8. Jeff KingJun 13, 2007
  9. Johannes SchindelinJun 13, 2007
  10. Jeff KingJun 13, 2007
  11. Johannes SchindelinJun 13, 2007
  12. Sam VilainJun 14, 2007
  13. Johannes SchindelinJun 14, 2007
  14. Sam VilainJun 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.