OKCOOL

Back

Sometimes it’s good to be lazy!

I love regular expressions, but it’s very easy to make a mistake if you don’t test well enough.

A found a good example of this recently where I was trying to find a specific attribute from a tag.

I used a regexp something like “(.+)” which works fine… until you end up getting more than one tag on the same line! The reason being that .+ is greedy…. it will keep going until it can’t find another “. This means it skips over the first closing ” and moves on to the next.

The solution was to make it lazy by using .+? instead!

Apologies for the fact this post seems slightly pointles, I’m actually testing a new plugin we’ve got for integrating wordpress in to swim.

  • Tom
  • 15 July 2008
  • 2 comments

Comments

Dug

said on 17 July 2008

Hi, will SWIM have support for typepad/movabletype or other bloggin platforms?

Mark

said on 20 July 2008

Dug,

We have a lot of plans for a lot of platforms… :)

Movabletype is definitely one of them. It took three days to get Wordpress in, although with more time it could probably be even better. I can’t imagine MT taking any longer, we need to find someone who knows MT well to integrate, the SWiM side of things is a piece of cake.

Know anyone?

Add a comment





OKCOOL Wordpress theme created by OKCOOL