Poll of the week: How should std.regex handle unknown escape sequences as in: "[\.]"

Jonathan M Davis jmdavisProg at gmx.com
Fri Dec 2 18:44:41 PST 2011


On Saturday, December 03, 2011 02:35:21 Jesse Phillips wrote:
> On Fri, 02 Dec 2011 17:59:59 -0500, Jonathan M Davis wrote:
> > On Friday, December 02, 2011 23:33:34 Marco Leise wrote:
> >> http://www.easypolls.net/poll.html?p=4ed9478e4fb7b0e4886eeea2
> > 
> > Why wouldn't std.regex accept an escaped sequence such as "\."? I
> > thought that the whole point of something like "\." was to make it so
> > that you could use "." directly in spite of the fact that it means
> > something special in regexes. Or is it something special to do with the
> > fact that it's between brackets? I'd still have thought that it would
> > just escape it, since it _is_ an escape sequence. Or is that the escape
> > sequence isn't necessary in between the brackets, and so the question is
> > how to handle it, since it isn't necessary?
> > 
> > - Jonathan M Davis
> 
> Brackets being a character class, dot is used literally. So in this case
> was it meant to be:
> 
> [\\.] or [.]

Well, then if \. is not legal, I'd expect a static assertion failure or a 
template constraint failure if the string were given as a compile-time 
argument and an exception if it were given as a runtime argument.

- Jonathan M Davis


More information about the Digitalmars-d mailing list