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: 2982854 |
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 How Can I Safely Remove a Column from an SQLite Table While Preserving Data?
- 2 How Can I Drop a Column from a SQLite Table?
- 3 How to Check if a URL Exists in C#?
- 4 Use LateX in Astro.js for Markdown Rendering
- 5 How Can I Efficiently Check if a URL Exists and Is Valid in C#?
- 6 How to Effectively Strip HTML Tags in ASP.NET?
- 7 How to Correctly Use GROUP Functions in MySQL Subqueries to Find Parts Supplied by Multiple Suppliers?
- 8 MySQL Error: "Invalid use of group function"—WHERE vs. HAVING: When Should I Use Which?
- 9 How to Fix MySQL's "Invalid Use of Group Function" Error in a Subquery?
- 10 Factors affecting the price of plastic spacers
- 11 Redefining Web Performance Standards with INP
- 12 Introducing KoiCom: A Library for Building Front-End Interfaces
- 13 How to Fix MySQL's "Invalid Use of Group Function" Error?
- 14 React Day Berlin Remote Reflections
- 15 Why Does MySQL Throw "Invalid use of group function" and How to Fix It Using HAVING?
Latest Tutorials
-
- Go language practical GraphQL
- 2487 2024-04-19
-
- 550W fan master learns JavaScript from scratch step by step
- 3886 2024-04-18
-
- Getting Started with MySQL (Teacher mosh)
- 2074 2024-04-07
-
- Mock.js | Axios.js | Json | Ajax--Ten days of quality class
- 2850 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.