python:twistedlxmlandre
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python:twistedlxmlandre [2015/10/09 02:48] – [re.findall] admin | python:twistedlxmlandre [2022/10/29 16:15] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 532: | Line 532: | ||
==== Regular Expression Language ==== | ==== Regular Expression Language ==== | ||
A regular expression (abbreviated regex or regexp) is a sequence of characters that forms a search pattern\\ | A regular expression (abbreviated regex or regexp) is a sequence of characters that forms a search pattern\\ | ||
- | refer: http:// | + | refer: |
+ | * http:// | ||
+ | * python: https:// | ||
**Match Character** | **Match Character** | ||
Line 585: | Line 587: | ||
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 692: | ||
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 702: | ||
## 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 alice@yo-yo-dyne.com, | ## purple alice@yo-yo-dyne.com, | ||
+ | </ | ||
+ | purple alice@yo-yo-dyne.com, | ||
</ | </ | ||
* 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.1444358929.txt.gz · Last modified: 2022/10/29 16:15 (external edit)