Skip to content

Commit 391a6f8

Browse files
committed
add regexp docs
1 parent d6fa48c commit 391a6f8

File tree

5 files changed

+1041
-1
lines changed

5 files changed

+1041
-1
lines changed

02-ruby-basics/02.03-strings.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@
597597
"cell_type": "markdown",
598598
"metadata": {},
599599
"source": [
600-
"`s.split(pattern, [limit])`以给定的pattern为分隔符对s进行分割。"
600+
"`s.split(pattern[, limit])`以给定的pattern为分隔符对s进行分割。"
601601
]
602602
},
603603
{

02-ruby-basics/02.04-symbols.ipynb

+82
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,88 @@
77
"# 符号"
88
]
99
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"## 创建 `Symbol`\n",
15+
"\n",
16+
"### 典型构造\n",
17+
"\n",
18+
"典型地,**Ruby**中可以在字符串之前加上 `:` 生成 `Symbol`。"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 2,
24+
"metadata": {},
25+
"outputs": [
26+
{
27+
"data": {
28+
"text/plain": [
29+
":hello"
30+
]
31+
},
32+
"execution_count": 2,
33+
"metadata": {},
34+
"output_type": "execute_result"
35+
}
36+
],
37+
"source": [
38+
":hello"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": 3,
44+
"metadata": {},
45+
"outputs": [
46+
{
47+
"data": {
48+
"text/plain": [
49+
":\"hello world\""
50+
]
51+
},
52+
"execution_count": 3,
53+
"metadata": {},
54+
"output_type": "execute_result"
55+
}
56+
],
57+
"source": [
58+
":'hello world'"
59+
]
60+
},
61+
{
62+
"cell_type": "markdown",
63+
"metadata": {},
64+
"source": [
65+
"### 特殊构造\n",
66+
"\n",
67+
"* %s: 不支持 `interpolation` 和 `escaping`\n",
68+
"* 你可以使用任何典型的分割字符,例如`%s{...}`, `%s(...)`, `%s|...|`, `%s?...?`, `%s-....-`, `%s/.../`, etc"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 4,
74+
"metadata": {},
75+
"outputs": [
76+
{
77+
"data": {
78+
"text/plain": [
79+
":\"this is \\\"hello\\\" 'world'\""
80+
]
81+
},
82+
"execution_count": 4,
83+
"metadata": {},
84+
"output_type": "execute_result"
85+
}
86+
],
87+
"source": [
88+
"s = %s(this is \"hello\" 'world')\n",
89+
"s"
90+
]
91+
},
1092
{
1193
"cell_type": "markdown",
1294
"metadata": {

0 commit comments

Comments
 (0)