Express.JS regular expression for example.com/:username

// ex: http://example.com/john_smith
app.get('/^(a-z)_(0-9)', function(req, res) {
    res.send('user'); 
});

//  ex: http://example.com/john_smith/messages/1987234
app.get('/^(a-z)_(0-9)/messages/:id', function(req, res) {
    res.send('message');
});

I wrote the above code for an app that I want to pass a username as a url variable to node.js like I would do: $username = $_GET['username']; in PHP. I'm not too good at writing regular expressions so I wanted to see if anyone could set me on the right track. Thanks in advance.

You're looking for req.params, which is an array of all of the capture groups in the regex.
The capture groups start at 1; req.params[0] is the entire match.

From your requirement it doesn't seem like you need a regular expression. Just use a a variable in your rule, like below:

// Grabs whatever comes after /user/ and maps it to req.params.id
app.get('/user/:id', function (req, res) {
    var userId = req.params.id;
    res.send(userId);
});

If you want to have better control, you could use a regular expression. To grab things you are interested in from the expression, use a capture group (which are typically expressed as a set of matching parenthesis):

// Grabs the lowercase string coming after /user/ and maps it to req.params[0]
app.get(/^\/user\/([a-z]+)$/, function (req, res) {
    var userId = req.params[0];
    res.send(userId);
});

A little off topic, but here's a really good intro to express.js that will help you understand it better (including how the routes work): http://evanhahn.com/understanding-express-js/