python:twistedlxmlandre
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
python:twistedlxmlandre [2015/10/09 02:48] – [re.findall] admin | python:twistedlxmlandre [2015/10/26 22:46] – [re.sub and re.compile] admin | ||
---|---|---|---|
Line 585: | Line 585: | ||
print email | print email | ||
</ | </ | ||
- | * [\w\.-]+ => Begin with one or multiple(sign: | + | * [\w\.-]+ => Begin with one or multiple(sign: |
+ | * @[\w\.-]+ => next of it is character @ and one or multiple characters in group: [word, **.** , **-**] | ||
- Example 2: <code python> | - Example 2: <code python> | ||
# Open file | # Open file | ||
Line 689: | Line 690: | ||
text2 = re.sub(" | text2 = re.sub(" | ||
print text2 | print text2 | ||
+ | </ | ||
+ | Python for beginner is a very good website | ||
</ | </ | ||
* Here is another example (taken from Googles Python class ) which searches for all the email addresses, and changes them to keep the user (1) but have yo-yo-dyne.com as the host.< | * Here is another example (taken from Googles Python class ) which searches for all the email addresses, and changes them to keep the user (1) but have yo-yo-dyne.com as the host.< | ||
Line 697: | Line 700: | ||
## 1 is group(1), 2 group(2) in the replacement | ## 1 is group(1), 2 group(2) in the replacement | ||
- | print re.sub(r' | + | print re.sub(r' |
## purple [email protected], | ## purple [email protected], | ||
+ | </ | ||
+ | purple [email protected], | ||
</ | </ | ||
* re.compile: With the re.compile() function we can compile pattern into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. | * re.compile: With the re.compile() function we can compile pattern into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. |
python/twistedlxmlandre.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1