Monday, 2 March 2009

Doing stuff

This morning I took some more flower photos and sorted some I'd taken over the last couple of days. In the garden I small a small hymenopteran inside a snowdrop and also heard what sounded like a bee.

After lunch I went on Animal Crossing for a few hours, just updating my items spreadsheet with what was in my catalog so I could see what I'd bought. Unfortunately I found (according to the spreadsheet at least) that some items I'd sold to Nook I couldn't re-buy from him. These were items I'd got from Sahara. I'm pretty sure I've also sold some Mario stuff in the past. So I didn't tick those items off if they were in my catalog but couldn't be bought from Nook.

Then I took some more flower photos, but then my camera battery ran out. After that I read the web squeeze for a bit and implemented the anti-spam measures people had suggested on there. One of them was to make sure that people don't enter multiple email addresses. I thought this would be a simple matter of changing my email checking regex, but I couldn't work out why it wasn't working.

I had my regex like this:
/^.+@.+\.[^@ ]+$/
And then input an email like 'j@j.co; l@l.c'. But the regex matched this email, even though it has 2 @ signs. It took me ages to work out what was happening. What happens is that the first . continues matching any char until it comes to the second @ sign, so the pattern is still being matched even when you do have 2 @ signs. With the way I'd written that regex, the only way it wouldn't match 2 @ signs would be if the email address was written like j@j.co; l@'.

So I changed the regex to this, which should match any email in the form x@x.x (where x is any combination of characters apart from @ or a space):
/^[^@ ]+@[^@ ]+\.[^@ ]+$/

After dinner I finished watching The Matrix with Mac and Ben, then finished off doing the anti-spam bits on my website. Then I read the web squeeze a bit more and someone had answered one of my other questions about passing an element to an onclick function. They said I needed to use a javascript closure. It worked in my example, but I haven't got it working in my real site so far as the default action of the click event is still happening, so I will have to read a bit more about javascript closures.

Food
Breakfast: Lemon marmalade toast sandwich; cup o' tea.
Lunch: Sliced pickled beetroot sandwich; banana; mince pie; Sainsbury's fake caramel Rocky; cup o' tea.
Afternoon snack: Cappuchino; Milk chocolate digestive.
Dinner: Spag bol; broccoli; little carrots. Pudding was a small cherry bakewell with custard. Coffee; Sainsbury's caramel chocolate.

No comments: