news aggregator

Does it .match?

Steve Slayer - Thu, 2008-08-28 18:43

I've been doing some work in AS3 of late and stumbled onto a bit of a gotcha last week that I thought I'd share since it caused me about 15 minutes of frustration.

The gotcha pertains to a significant difference in how Javascript and AS3 handle the match method of the String object when the global flag is passed. Consider the following Javascript snippet:

var r = /[a-z]/g
var s = "abc";
var x = s.match(r);

This will return an Array with values "a,b,c" in both Javascript and in its AS3 equivalent.

Now, consider this code, replacing the value of s with something that will not match:

var r = /[a-z]/g
var s = "123";
var x = s.match(r);

In Javascript, this will return null, but AS3 will return a zero length Array. Which means that this...

if(s.match(r)) {
// do stuff...
}

..would always be true in AS3, but false in Javascript. I spent about 10 minutes thinking there was something wrong with my regular expression, and another five thinking there was something wrong with AS3's regexp engine before I realized what was happening.

So who has it right? According to the ECMA 262 spec, AS3 does (see page 101-102). Of course, Mozilla's documentation claims that it will return an Array as well with no mention of null on that page, while Microsoft's JScript documentation admits it will return null if no match is found.

Good times.

Emre Grayson Chipman

Steve Slayer - Thu, 2008-08-28 18:43

My son, born this evening weighing in at 9.33 pounds, measuring 20 inches.

(And that's why I wasn't in Austin this year!)

SXSW Time!

Steve Slayer - Thu, 2008-08-28 18:43

And I'm not gonna be there this year. I know, I know - I should have told you sooner. You're probably already in Austin or in flight, now wishing you had advance notice of this turn of events so you could have just stayed home. I'm sorry, I really am. This really was terribly inconsiderate of me.

Soldier on, brave geeks, and know that with enough Shiner Bock, anything can be fun even if I'm not there. Be strong. And take lots of pictures. And twitter a lot. Let me experience Austin through your internets.

(Any day now I'll have an announcement of why I'm not there this year...)

Three Drawings and a PSA

Steve Slayer - Thu, 2008-08-28 18:43

These three drawings I did leading up to Christmas - I've kept them private on Flickr and not published them here as they were gifts for family and I didn't want to spoil the suprise.

Colored Pencil Drawing entitled Clara at 17 Months

  • Clara at 17 Months
  • 8 x 10"
  • Colored Pencil on Eggshell Mi-Tients Paper
  • November 20, 2007

Colored Pencil drawing entitled Big Smile

  • Big Smile
  • 8 x 10"
  • Colored Pencil on Cream Mi-Tientes Paper
  • December 11, 2007

Colored Pencil drawing entitled Clara at 18 Months

  • Clara at 18 Months
  • 10 x 8"
  • Colored Pencil on Eggshell Mi-Tientes Paper
  • December 21, 2007

And with those, I'll no longer be posting drawings on slayeroffice. 2008 seems a good a time as any to get the site back on the web development talk track. If you're interested in following my portraiture work, you can find it on my new drawing blog. Or, just grab the feed.

Page 222

Steve Slayer - Thu, 2008-08-28 18:43

My good pal Mr. Lawver has included a reference to my Page Info Favelet on page 222 of his new book.

Congratulations to Kevin, Kimberly, Christopher, Rob, Meryl and Mark on the book. I'm not sure when it comes out, but with that caliber of authorship (and obvious good taste) its a must-own.

Maya

Steve Slayer - Thu, 2008-08-28 18:43

Graphite portrait of a friend's new baby entitled Maya

  • Maya
  • Graphite on Cold Press Illustration Board
  • 11 x 8.5"

A portrait of a friend's new baby.

Self Portrait III

Steve Slayer - Thu, 2008-08-28 18:43

Graphite drawing entitled Self Portrait III

My first go at graphite in about 12 years. It didn't take nearly as long as a colored pencil drawing, and it was awfully nice to be able to use an eraser. I may stick with it for a little while.

The Angry Cow

Steve Slayer - Thu, 2008-08-28 18:43

Colored pencil portrait entitled Clara the Angry Cow

Clara in her Halloween costume impersonating her Daddy's scowl.

As well, Happy 5th Birthday, slayeroffice!

Brian

Steve Slayer - Thu, 2008-08-28 18:43

Colored pencil portrait entitled Brian

Max & Clara

Steve Slayer - Thu, 2008-08-28 18:43

Colored pencil drawing entitled Max

A finished this one a week or so ago but forgot to post:

Colored Pencil portrait entitled Clara at 15 Months II

The Funny Firm

BBC Comedy - Thu, 2008-08-28 18:43
Doco to examine the business of comedy
Categories: Comedy

What Are The Odds?

BBC Comedy - Thu, 2008-08-28 18:43
Walliams is the favourite to win sporting honour.
Categories: Comedy

Three's Company

BBC Comedy - Thu, 2008-08-28 18:43
Digital channel's autumn comedy line-up.
Categories: Comedy

The Tuesday Filter

BBC Comedy - Thu, 2008-08-28 18:43
Take a tequila shot of comedy news, then suck on the lime of credibility.
Categories: Comedy

One Laugh

BBC Comedy - Thu, 2008-08-28 18:43
BBC ONE's autumn comedy line-up
Categories: Comedy

It's About Time

BBC Comedy - Thu, 2008-08-28 18:43
Revealed: Details of Armando Iannucci's latest comedy
Categories: Comedy

Bruce's Bonus

BBC Comedy - Thu, 2008-08-28 18:43
Radio 2 honours the iconic Lenny Bruce
Categories: Comedy

Omid's Big One

BBC Comedy - Thu, 2008-08-28 18:43
Djalili lands major BBC show
Categories: Comedy

The Friday Filter

BBC Comedy - Thu, 2008-08-28 18:43
Picking the bobbly ones from the Liquorice Allsorts of the media sweetshop
Categories: Comedy

The British Are Coming!

BBC Comedy - Thu, 2008-08-28 18:43
UK comedy hits head to the States
Categories: Comedy