While it can be very intimidating because you don't know what it means, it's really not that hard to read. I would suggest the book "mastering regular expressions" by Jeffrey Friedl. It helped me make sense of what was once gibberish. Others have already explained what it does so I won't go over that again but I don't think regular expressions should be feared. A read through "Mastering Regular Expressions" should make a master out of anyone.
I also want to say that I disagree with the notion that you should always use /x to make your code clearer. If you do, you are relying on what the comments say, not on what the regex says. To me, when you spread it out like that, it makes it easier to comment but harder to actually read and find errors. (in my opinion) I think it's all the whitespace around the regex that makes it harder for me to understand. I agree most code is under commented but /x tends to lead to overcommenting for people who don't really understand regex's.
ps. I have no affiliation with the author or the publishers other than I bought the book and loved it
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|