digitalmars.D - regular expressions
Hi, just as a short note, is seems as if either a. the regex parser does not work as documented, or b. I have somehow messed up. To be precise, http://www.digitalmars.com/ctg/regular.html says that "." matches any character. I seem to have found at least one exception, the newline character "\n". Example the string "abc\ndef" is not matched by "^\".*\"$", but is by "^\"(.|\n)*\"$". Can anyone confirm? Happy hacking, 0ffh
Mar 11 2007
0ffh wrote:Hi, just as a short note, is seems as if either a. the regex parser does not work as documented, or b. I have somehow messed up. To be precise, http://www.digitalmars.com/ctg/regular.html says that "." matches any character. I seem to have found at least one exception, the newline character "\n". Example the string "abc\ndef" is not matched by "^\".*\"$", but is by "^\"(.|\n)*\"$". Can anyone confirm?It's standard in regex syntax that the dot doesn't match a newline. Should probably have been mentioned in the docs, though. Usually there's modifier than makes the dot match newlines too, but I can't see one on that page.
Mar 11 2007
torhu wrote:0ffh wrote:Well, that would appear to be the reason, then. As I have found a trivial workaround, it's just as well.... :) Thanks, 0ffh[...] To be precise, http://www.digitalmars.com/ctg/regular.html says that "." matches any character. I seem to have found at least one exception, the newline character "\n". [...]It's standard in regex syntax that the dot doesn't match a newline. Should probably have been mentioned in the docs, though. [...]
Mar 11 2007