Jul 14

What does this mean? Well for starters, those nice little PCRE shorthands for character classes just don’t work! So putting this in your Varnish VCL will silently do nothing:

if (req.url ~ "/\d+(/$|/\?|\?|$)") ...

whereas this match:

if (req.url ~ "/[0-9]+(/$|/\?|\?|$)") ...

Enjoy.

Tagged with:
Jun 05

Simple but effective regex to monitor when there are issues. In my example below, this will show all response times > 1 second:

 tail -f production.log | egrep "Completed in [0-9]{3,10}"

Tagged with:
Mar 01

I whipped this up to remove all spans and/or divs in an HTML. Don’t ask why. Here’s the regex:

< ?(span|div)[a-zA-Z0-9'" =]+>

Did I mention I love regex?

Enjoy.

Tagged with:
Jan 12

When needing to perform a String.replace() with some regex and globally replace text. You must remember to put the “g” argument like so:

var str = “‘http://www.com/123/123′”

str.replace(/’/g,”")

Spent a few minutes banging my head on this one.  So remember the “g”!

Tagged with: