Commits

Shlomi Fish committed aa8fb49

Add the dot-asterisk item

  • Participants
  • Parent commits dbb1765

Comments (0)

Files changed (3)

     - long lines in source code.
     - grep !/\A\./ for getting rid of "." and ".." in readdir().
     - assigning a list to a scalar.
+    - Regular expressions starting or ending with .*? or .*
         - show all with IO::All and without it.
 
 * Add to '/bad-elements/':
-    - Regular expressions starting or ending with .*? or .*
     - Using one variable for two different things
         - assignment to a different value in the middle of the subroutine.
     - Recursively iterating over directories and sub-directories instead of

src/tutorials/bad-elements/index.html.wml

 
 </item>
 
+<item id="dot_asterisk" h="Regular Expressions starting or ending with “.*”">
+
+<p>
+It is not necessary to put <tt>.*</tt> or <tt>.*?</tt> into the beginning or
+end of regular
+expressions to match something anywhere inside the string. So for example
+<tt>if ($hay_stack =~ /.*ab+c.*/)</tt> can be replaced with the simpler:
+<tt>if ($hay_stack =~ /ab+c/)</tt>. If you wish to match and extract the
+prefix, you should say <tt>(.*?)</tt> or <tt>(.*)</tt>.
+</p>
+
+</item>
+
 </main_list>
 
 #include "bad-elements-sources.wml"