Skip to content

Commit 152e815

Browse files
committed
Emphasize Unicode-aware features in Chapter 9
1 parent 63a20c9 commit 152e815

File tree

6 files changed

+145
-501
lines changed

6 files changed

+145
-501
lines changed

Diff for: 05_higher_order.md

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ There is a built-in array method, `forEach`, that provides something like a `for
202202
// → B
203203
```
204204

205+
{{id scripts}}
206+
205207
## Script data set
206208

207209
One area where higher-order functions shine is data processing. To process data, we'll need some actual data. This chapter will use a ((data set)) about scripts—((writing system))s such as Latin, Cyrillic, or Arabic.

Diff for: 09_regexp.md

+106-117
Large diffs are not rendered by default.

Diff for: code/solutions/09_1_regexp_golf.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ verify(/ferr(et|y|ari)/,
1212
["ferret", "ferry", "ferrari"],
1313
["ferrum", "transfer A"]);
1414

15-
verify(/ious\b/,
15+
verify(/ious($|\P{L})/u,
1616
["how delicious", "spacious room"],
1717
["ruinous", "consciousness"]);
1818

1919
verify(/\s[.,:;]/,
2020
["bad punctuation ."],
2121
["escape the dot"]);
2222

23-
verify(/\w{7}/,
23+
verify(/\p{L}{7}/u,
2424
["Siebentausenddreihundertzweiundzwanzig"],
2525
["no", "three small words"]);
2626

27-
verify(/\b[^\We]+\b/i,
27+
verify(/(^|\P{L})[^\P{L}e]+($|\P{L})/i,
2828
["red platypus", "wobbling nest"],
29-
["earth bed", "learning ape", "BEET"]);
29+
["earth bed", "bedrøvet abe", "BEET"]);
3030

3131

3232
function verify(regexp, yes, no) {

Diff for: code/solutions/09_2_quoting_style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let text = "'I'm the cook,' he said, 'it's my job.'";
22

3-
console.log(text.replace(/(^|\W)'|'(\W|$)/g, '$1"$2'));
3+
console.log(text.replace(/(^|\P{L})'|'(\P{L}|$)/gu, '$1"$2'));
44
// → "I'm the cook," he said, "it's my job."
55

Diff for: img/re_number.svg

+15-72
Loading

0 commit comments

Comments
 (0)