On Mon, 31 Jan 2011 03:57:44 +0200, Alex Folland <lexlex...@gmail.com> wrote:

I wrote this little program to test for regular expression matches. I compiled it with in Windows with DMD 2.051 through Visual Studio 2010 with Visual D. It crashes if regexbuf is just the single character, "*". Why? Shouldn't it match the entire string?

"*" in regular expressions means 0 or more instances of the previous entity:
http://www.regular-expressions.info/repeat.html
It doesn't make sense at the start of an expression. ".*" is the regexp that matches anything[1].

std.regex probably can't handle invalid regexps very well. Note that std.regex is a new module that intends to replace the older std.regexp, but still has some problems.

Also, why does it match an unlimited number of times on "$" instead of just once?

Looks like another std.regex bug.

My debug build is here: http://lex.clansfx.co.uk/projects/regextester.exe

A note for the future: compiled executables aren't very useful when source is available, especially considering many people here don't use Windows.

[1]: A dot in a regular expression may not match newlines, depending on the implementation and search options.

--
Best regards,
 Vladimir                            mailto:vladi...@thecybershadow.net

Reply via email to