current location: Home > Download > Learning resources > Web page production > Detailed explanation of python-regular re module

Detailed explanation of python-regular re module
Classify: Learning materials / Web page production | Release time: 2018-01-12 | visits: 2982961 |
Download: 205 |
Latest Downloads
Horror Beat Phase Maker
Himalayan Children
Zebra AI
Supermarket Manager Simulator
Red Alert Online
Delta Force
Pokémon UNITE
Fantasy Aquarium
Girls Frontline
Wings of Stars
24 HoursReading Leaderboard
- 1 How to fix error 1628: Failed to complete installation error in Windows?
- 2 6 Reasons to Avoid Buying a Used Phone
- 3 How to find my games on Windows 10/11?
- 4 How to uninstall MS Edge (Chromium) in Windows?
- 5 Fix Windows Keeps Assigning Drive Letter to Recovery Partition
- 6 Virtual currency trading platform app ranking Rui
- 7 Top 10 official virtual currency trading apps Top 10 official virtual currency trading platforms for mobile phones
- 8 Top 10 virtual currency trading app rankings Top 10 virtual currency trading app recommendations
- 9 A summary of the top ten virtual currency trading platforms apps, ranking of the top ten virtual currency trading platforms 2025
- 10 Which of the top ten virtual currency trading apps is the best? Which of the top ten virtual currency trading apps is the most reliable
- 11 What is the current price of Bitcoin?
- 12 The difference between Ether and Bitcoin What is the difference between Ether and Bitcoin
- 13 Top 10 virtual currency trading platform app rankings Top 10 virtual currency trading platform rankings
- 14 How to choose an exchange for currency trading
- 15 What are the advantages and disadvantages of controlled and uncontrolled components?
Latest Tutorials
-
- Go language practical GraphQL
- 2986 2024-04-19
-
- 550W fan master learns JavaScript from scratch step by step
- 4327 2024-04-18
-
- Getting Started with MySQL (Teacher mosh)
- 2335 2024-04-07
-
- Mock.js | Axios.js | Json | Ajax--Ten days of quality class
- 3076 2024-03-29
The function prototype of re.sub is: re.sub(pattern, repl, string, count)
The second function is the replaced string; in this case it is '-'
The fourth parameter refers to the number of replacements. Defaults to 0, meaning every match is replaced.
re.sub also allows sophisticated handling of replacement of matches using functions. For example: re.sub(r'\s', lambda m: '[' m.group(0) ']', text, 0); Replace the space ' ' in the string with '[ ]'.
re.split
You can use re.split to split a string, such as: re.split(r'\s ', text); split the string into a word list by spaces.
re.findall
re.findall can get all matching strings in the string. For example: re.findall(r'\w*oo\w*', text); Get all words containing 'oo' in the string.
re.compile
Regular expressions can be compiled into a regular expression object. Frequently used regular expressions can be compiled into regular expression objects, which can improve certain efficiency.
