From 4777d1293c5c368f17cb5a8bbd502cc0314d137e Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 1 Jun 2011 14:26:50 +1000 Subject: [PATCH] Add note about matching whitespace in heregexes. --- chapters/regular_expressions/heregexes.textile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chapters/regular_expressions/heregexes.textile b/chapters/regular_expressions/heregexes.textile index 0337b23..cc913c9 100644 --- a/chapters/regular_expressions/heregexes.textile +++ b/chapters/regular_expressions/heregexes.textile @@ -25,3 +25,12 @@ pattern = /// h2. Discussion Breaking up your complex regular expressions and commenting key sections makes them a lot more decipherable and maintainable. For example, changing this regex to allow an optional space between the prefix and line number would now be fairly obvious. + +h3. Whitespace characters in heregexes + +Whitespace is ignored in heregexes -- so what do you do if you need to match a +literal ASCII space? + +One solution is to use the @\s@ character class, which will match spaces, tabs +and line breaks. If you only want to match a space, though, you'll need to use +@\x20@ to denote a literal ASCII space.