擅长:python、mysql、java
<p>您可以在regex中使用注释,这使它们更具可读性。以<a href="http://gnosis.cx/publish/programming/regular_expressions.html" rel="nofollow noreferrer">http://gnosis.cx/publish/programming/regular_expressions.html</a>为例:</p>
<pre><code>/ # identify URLs within a text file
[^="] # do not match URLs in IMG tags like:
# <img src="http://mysite.com/mypic.png">
http|ftp|gopher # make sure we find a resource type
:\/\/ # ...needs to be followed by colon-slash-slash
[^ \n\r]+ # stuff other than space, newline, tab is in URL
(?=[\s\.,]) # assert: followed by whitespace/period/comma
/
</code></pre>