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

Classify: Learning materials / Web page production | Release time: 2018-01-12 | visits: 2982916 |
Download: 204 |
Latest Downloads
Red Alert Online
Delta Force
Pokémon UNITE
Fantasy Aquarium
Girls Frontline
Wings of Stars
Little Flower Fairy Fairy Paradise
Restaurant Cute Story
Shanhe Travel Exploration
Love and Producer
24 HoursReading Leaderboard
- 1 Mystic Messenger chat schedules: A complete spoiler-free Mystic Messenger walkthrough including all Casual Story, Deep Story, and Another Story chatrooms
- 2 The Sims: How To Use Your Free Magic Kit
- 3 How to fix Windows update error 0x80240035?
- 4 Monopoly Go Altruistic Auction rewards
- 5 Days Gone Remasetered Pre-Order Guide: Bonuses, Release Date, And Upgrade Path
- 6 How to fix Microsoft Store stuck on updating?
- 7 NYT Connections Answers And Hints - February 21, 2025 Solution #621
- 8 Best Fixes for Avowed Fatal Error UE Alabama Game Has Crashed
- 9 Formal digital currency trading platform ranking of top ten digital currency app platforms
- 10 Top 10 Virtual Digital Currency Exchanges Rankings in 2025 Latest Authoritative Rankings
- 11 Sesame Exchange Official Registration Portal
- 12 Top 10 Currency Trading Apps Ranking in 2025 The authoritative list of must-see virtual currency apps for investment
- 13 Recommended top ten trading apps for currency speculation. What are the top ten trading apps for currency speculation?
- 14 gate.io exchange official website entrance
- 15 What are the top ten trading platforms for cryptocurrency speculation? Top 10 Currency Exchanges in 2025 List
Latest Tutorials
-
- Go language practical GraphQL
- 2776 2024-04-19
-
- 550W fan master learns JavaScript from scratch step by step
- 4151 2024-04-18
-
- Getting Started with MySQL (Teacher mosh)
- 2242 2024-04-07
-
- Mock.js | Axios.js | Json | Ajax--Ten days of quality class
- 2994 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 '[ ]'.
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 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.
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.