A Path Less Taken

Breaking with convention in a very conventional fashion.
Powered by WordPress

Regular Expressions Revisited


08 / 2009

I’ve been working on a new application and I wanted to do URL re-writing in LightTPD. I was having trouble coming up with a regular expression (regex) that worked. If found some references that were pretty helpful and that allowed me to accomplish what I wanted. I’m listing them here in the hopes they might be helpful to you.

Those were the references that worked for me. The actual mod_rewrite rule is provided below in case it’s useful as a reference.

$HTTP["host"] =~ "localhost:81" {
	url.rewrite-once = (
		"/go/(list|view)/([0-9]+)/*$" => "/go/index.php?$1=$2"

I hope this was helpful to you.

Update: I found another regular expression test tool that worked with the preg_match method of PHP. The Regular Expression Test Tool was helpful in finding a syntax problem for PHP that was not apparent in the gskinner.com tool. They are both excellent and the gskinner.com tool is faster to use, but this one was great for solving my PHP problem.


No comments found. Please enter a comment if you have a question or contribution.


Post a comment

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *