Skip to content

Commit 8e58565

Browse files
committed
Merge pull request coffeescript-cookbook#13 from nornagon/master
Added a note about whitespace to heregex recipe
2 parents 1586e44 + 4777d12 commit 8e58565

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

chapters/regular_expressions/heregexes.textile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@ pattern = ///
2525
h2. Discussion
2626

2727
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.
28+
29+
h3. Whitespace characters in heregexes
30+
31+
Whitespace is ignored in heregexes -- so what do you do if you need to match a
32+
literal ASCII space?
33+
34+
One solution is to use the @\s@ character class, which will match spaces, tabs
35+
and line breaks. If you only want to match a space, though, you'll need to use
36+
@\x20@ to denote a literal ASCII space.

0 commit comments

Comments
 (0)