User Tools

Site Tools


python:twistedlxmlandre

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
python:twistedlxmlandre [2015/10/09 02:51] – [re.findall] adminpython: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://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx+refer:  
 +  * http://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx 
 +  * python: https://docs.python.org/2/library/re.html#regular-expression-syntax
  
 **Match Character** **Match Character**
Line 690: Line 692:
 text2 = re.sub("cool", "good", text) text2 = re.sub("cool", "good", text)
 print text2 print text2
 +</code>output<code>
 +Python for beginner is a very good website
 </code> </code>
       * 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.<code python>       * 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.<code python>
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'([w.-]+)@([w.-]+)', r'[email protected]', str) +print re.sub(r'([\w.-]+)@([\w.-]+)', r'[email protected]', str)
 ## purple [email protected], blah monkey [email protected] blah dishwasher ## purple [email protected], blah monkey [email protected] blah dishwasher
 +</code>output:<code>
 +purple [email protected], blah monkey [email protected] blah dishwasher
 </code> </code>
   * 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.1444359063.txt.gz · Last modified: 2022/10/29 16:15 (external edit)