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/26 22:40] – [re.sub and re.compile] 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 690: | 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 698: | 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@google.com, blah monkey bob@abc.com blah dishwasher | + | purple alice@yo-yo-dyne.com, blah monkey bob@yo-yo-dyne.com blah dishwasher |
| </ | </ | ||
| * 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.1445899219.txt.gz · Last modified: (external edit)
