You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Andrey Somov <tr...@googlemail.com> on 2011/04/08 13:16:08 UTC

couch_config_writer.erl: meaning of single backslash in regular expression

Hi all,
the line 34 of couch_config_writer.erl (
https://svn.apache.org/repos/asf/couchdb/trunk/src/couchdb/couch_config_writer.erl
)
contains a regular expression:

{ok, Pattern} = re:compile(["^(", Key, "\\s*=)|\\[[a-zA-Z0-9\_-]*\\]"]),

What does the single backslash mean (\_)? When I remove it the tests still
succeed. (to be precise they fail in the same way as with the single
backslash)

-
Andrey

Re: couch_config_writer.erl: meaning of single backslash in regular expression

Posted by Andrey Somov <tr...@googlemail.com>.
I was asking the question because I was not sure whether the Erlang's
dialect has a special meaning for "escaped" underscore.
I am afraid it is just a minor bug.
Shall I create an issue ?

-
Andrey

On Fri, Apr 8, 2011 at 1:20 PM, Dirkjan Ochtman <di...@ochtman.nl> wrote:

> On Fri, Apr 8, 2011 at 13:16, Andrey Somov <tr...@googlemail.com>
> wrote:
> > {ok, Pattern} = re:compile(["^(", Key, "\\s*=)|\\[[a-zA-Z0-9\_-]*\\]"]),
> >
> > What does the single backslash mean (\_)? When I remove it the tests
> still
> > succeed. (to be precise they fail in the same way as with the single
> > backslash)
>
> I'm guessing it's supposed to be an escape character, but I don't know
> of any regex dialect where the underscore is meaningful inside a
> character range.
>
> Cheers,
>
> Dirkjan
>

Re: couch_config_writer.erl: meaning of single backslash in regular expression

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Fri, Apr 8, 2011 at 13:16, Andrey Somov <tr...@googlemail.com> wrote:
> {ok, Pattern} = re:compile(["^(", Key, "\\s*=)|\\[[a-zA-Z0-9\_-]*\\]"]),
>
> What does the single backslash mean (\_)? When I remove it the tests still
> succeed. (to be precise they fail in the same way as with the single
> backslash)

I'm guessing it's supposed to be an escape character, but I don't know
of any regex dialect where the underscore is meaningful inside a
character range.

Cheers,

Dirkjan