Take the 2-minute tour ×

The Ruby in Tim Bray's Wide Finder benchmark (http://wikis.sun.com/display/WideFinder/The+Benchmark) has this line:


I've been using regexes for a long time, but I'm not sure what the point of the "." is. It seems to match on anything that's not a space, but [^ ] would do that anyway.

When I first looked at it, it looked to me like it would match on nothing except possibly a line break.

Can anybody explain the behavior of this expression?

share|improve this question
\d\d\d\d == \d{4} –  hsz Dec 24 '09 at 0:31
By the way, it's generally good to accept an answer if it meets your needs. You replied to Mark's comment saying "Perfect", but haven't accepted it. You can accept it by clicking on the large check mark that should appear to the left of the answer (under the score). –  Brian Campbell Dec 24 '09 at 2:16

1 Answer 1

[^ .] means match any single character apart from a space or a literal period. The period does not have a special meaning when inside square brackets.

share|improve this answer
Perfect. Thanks much. –  sbrian Dec 24 '09 at 1:08

Your Answer


