Here is a pattern that should work: ^\>([\dnsewud]+)
Then, you can use some code like this to pull the directions apart and send the relevant commands:
Just know that if you want to move one space to the east or west, you will need to precede it with a 1, instead of not using a number, or it could cause confusion to the script (this is obvious for cases like 'ne', 'sw', etc., but also applies to all other cases, such as 'de', 'uw', 'ew').