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: 2983128 |
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 LG OLED TV I'd pair with the Switch 2 just got Memorial Day'd
- 2 How to handle errors during XML parsing?
- 3 How to Fix Win Update Error 0x800b0100
- 4 C# singleton pattern implementation
- 5 What's the difference between YouTube Music and YouTube Premium?
- 6 How to optimize a blog post for seo
- 7 How to fix the "Target class does not exist" error in Laravel?
- 8 NYT ‘Strands’ Hints, Spangram And Answers For Monday, August 25
- 9 How to implement a fan-in, fan-out concurrency pattern in Golang
- 10 How to Resolve a "Purchase Failed" or "Unexpected Error" on Steam
- 11 How to link a JavaScript file to HTML
- 12 Darth Vader's Star Wars Lightsaber Prop Slays At Auction With Massive Winning Bid
- 13 Implement condition display based on JavaScript confirm: Dynamically control element visibility
- 14 How To Add Program To Start Menu Windows 10
- 15 WooCommerce Custom WP_Query Solution for an error while getting order details
Latest Tutorials
-
- Go language practical GraphQL
- 4083 2024-04-19
-
- 550W fan master learns JavaScript from scratch step by step
- 5392 2024-04-18
-
- Getting Started with MySQL (Teacher mosh)
- 3458 2024-04-07
-
- Mock.js | Axios.js | Json | Ajax--Ten days of quality class
- 3949 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.
