程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python tutorial using Python and graphviz animated regular expressions to explore the interior of the regular expression engine

編輯:Python


Regular expressions have a bad reputation . It seems that whenever they are mentioned , It will call the image of the terrible text wall , These images look absolutely nonsense . for example , This is a common regular expression used to validate email addresses :

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/ =?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\ [\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0 -9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0- 5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0 -4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\ x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Oh dear . I will not pretend that you will understand this expression at the end of this article , But at least I want to show you that it is based on simple rules , These rules are not difficult to understand .

You may want to know , Why should you care first about how these things work ? I think there are several good reasons . The first is that understanding the basics makes it easier to remember how to write good regular expressions .

I must have encountered many situations , I wrote a regular expression , Then you don't need to see it for months . When I finally got back to it , I've forgotten everything , Have to start from scratch


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved