[Top][All Lists]

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

Re: Unquoted special characters in regexps

From: Luc Teirlinck
Subject: Re: Unquoted special characters in regexps
Date: Fri, 3 Mar 2006 17:00:40 -0600 (CST)

Martin Rudalics wrote:

   Nowadays I'd probably write something like

   "[^\\]\\(\\\\\\{2\\}*\\)\"[ \t,]*"

   but maybe at the time the original expression was written repetition
   operators were not yet available.

To me, the above regexp is _really_ awkward, whereas

"[^\\]\\(\\([\\][\\]\\)*\\)\"[ \t,]*"

is really easy to understand and very self-documenting.

   However, writing `[\\]' to match a single backslash is dreadful as well.

Quite to the contrary.  It documents very clearly which \\ together
represent one single literal backslash and it separates them clearly
from the surrounding non-literal backslashes.  It is what makes this
regexp so very easy to read, unlike your suggested replacement with
its six consecutive ungrouped backslashes, with various different



reply via email to

[Prev in Thread] Current Thread [Next in Thread]