跟讀練習: [Practice Problems] Regular Expressions (Regex) - Visually Explained - 通過影片學習英語口語

選擇練習模式

每種模式都會開啟全屏練習室。

61 句
如果句子過短或過長,請點選 Edit 進行調整。
1
Have you tried our regular expressions practice exercises?
2
If you have, great!
3
We're going to work through the solutions now.
4
If not, the problems are linked in the description.
5
Alright, let's start with problem one.
6
In this problem, we want to match all the phone numbers from the bulletin board text.
7
Each phone number follows the format.
8
A fixed area code, and a hyphen, followed by three digits, another hyphen, and a final four digits.
9
Since every phone number starts with the same area code and hyphen, we write the literal characters 1, 2, 3, hyphen directly into the pattern box.
10
Next, the middle group of numbers can have any combination of three digits.
11
To match this, we use the character class 0 through 9 to match a single digit
12
and follow it with the quantifier 3 to match exactly 3.
13
Following the character class, we write another literal hyphen.
14
To match the last four digits, like the middle three, we use a character class with 0 through 9.
15
But to match four digits instead of 3, we use a quantifier of 4.
16
Great!
17
As we can see, this pattern matches both phone numbers and our bulletin board text.
18
Fixed quantifiers like 3 and 4 are ideal when you know the exact length you're looking for.
19
Phone numbers, zip codes, product codes, anything with a predictable structure.
20
Quantifiers will also be quite useful in problem 2.
21
In this problem, we want to write a regular expression to match all the prices in our text string.
22
each price starts with a dollar sign followed by one
23
or more digits a dot
24
and exactly two digits for cents you might be tempted to start by writing the literal dollar sign character
25
but in regex dollar sign is a special syntax
26
that means end of line
27
so it won't match the dollar sign character to match a
28
literal dollar sign we put a backslash in front of it after the dollar sign comes the digits before the decimal,
29
which we can match using a character class with 0 through 9.
30
Since there could be any number of digits before the decimal, we use the plus quantifier to match one or more digits.
31
Following this character class, we specify a dot.
32
Remember, like the dollar sign, the dot is special syntax, called a wildcard, that matches any single character.
33
To use a literal dot character, we need to write a backslash before it.
34
Finally, cents always have exactly two digits.
35
To match this, we write a character class allowing the digits 0 through 9 and a quantifier of 2.
36
Awesome!
37
With this pattern, all five prices are matched.
38
Before we move on, we've now written the character class containing 0 through 9 several times.
39
Since this is such a common pattern, regex syntax actually provides a shorthand for it.
40
Instead of explicitly writing the character class, we write backslash d, which also means any digit.
41
Awesome, our pattern is now more concise and we still get the same matches.
42
We'll use the digit shorthand backslash d again in problem 3.
43
In this problem, we want to match all the dates in the text.
44
Each date has a month name, a day number, and a four-digit year.
45
We'll start by matching the month names.
46
Month names are made up of letters, both upper and lowercase, so we'll use a character class of all the uppercase and lowercase letters.
47
To match one or more letters, we follow the class with the plus quantifier.
48
After the month name comes a literal space.
49
After the space, the day can be one digit or two.
50
To match exactly one or two digits,
51
we use the backslash d shorthand followed by a range quantifier with a lower bound of one and upper bound of two.
52
Following the day, we write a literal comma and space.
53
Lastly, the year is always four digits, so we write the digit shorthand and a quantifier of four.
54
Awesome!
55
With that pattern, we've matched all the dates.
56
With these practice problems, you've seen how to write patterns for three different data types.
57
If you want to go deeper on any of the concepts we used in this video, check out our regular expressions intro video linked in the description.
58
We're working on lots more Python explainer videos like this one, so be sure to subscribe so that you don't miss out.
59
If you have any questions or topics that you'd like to learn about, let us know in the comments below.
60
We'd love to hear from you.
61
Thanks for watching!

下載應用

流利口語所需的一切

AI 發音評分逐句打分
音標練習掌握每個音
詞彙學習建立你的詞庫
詞彙遊戲邊玩邊學
FOR YOU

推薦影片

關於本課

在本課中,我們將通過實際練習來掌握正規表示式的應用。這包括匹配電話號碼、價格和日期等常見格式。通過實踐,我們可以學會如何使用正規表示式的語法來提取文本中的資訊,從而提升我們的英語理解能力。這些內容不僅對提升英語發音有幫助,也能為雅思口語練習打下良好的基礎。

關鍵詞彙與短語

  • 正規表示式 - 一種用於匹配字串的規則。
  • 電話號碼 - 特定格式的數字串,用於聯絡。
  • 價格 - 帶有貨幣符號的數字。
  • 日期 - 由月份、日期和年份構成的字串。
  • 字元類 - 匹配特定型別字元的集合。
  • 量詞 - 指定匹配字元的數量。
  • 萬用字元 - 用於匹配任何單個字元的符號。
  • 反斜槓 - 用於轉義特殊字元的符號。

練習技巧

在進行英語影子跟讀時,建議你跟隨影片中的節奏來模仿練習。這種 shadow speak 方法能有效提高你的英語發音和流利度。影片所用的語速適中,非常適合進行逐字跟唱。當你聽到每個正規表示式的構建時,嘗試大聲朗讀並同時理解每個部分的功能。例如,聽到“字元類”時,可以即時模仿發音,並同時理解其含義。通過這樣的反覆練習,不僅能幫助你更好地掌握正規表示式的概念,也能提升你在實際對話中的反應能力,為雅思口語練習提供更多支援。

在模仿過程中,可以多次暫停影片,確保聽懂每個術語和其應用。逐漸加快跟讀速度,挑戰自己的發音和語調。有意識地練習可以幫助你在真實語境中更自信地使用英語。

影片中的語法

說話人最常用的結構,並附上影片中的原話:

結構影片中的用法
現在完成時 have/has + 過去分詞 — 過去發生但與現在仍有關聯的事Have you tried · we've now written · we've matched
被動語態 be + 過去分詞 — 強調發生了什麼,而不是誰做的are linked · might be tempted · are matched

什麼是跟讀法?

跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。

影子跟讀法: 閱讀完整分步指南 →