How can I match a twitter username with angular ui router

Posted by user3929999 on Stack Overflow See other posts from Stack Overflow or by user3929999
Published on 2014-08-23T09:52:38Z Indexed on 2014/08/23 10:20 UTC
Read the original article Hit count: 275

I need to be able to match a path like '/@someusername' with angular ui router but can't figure out the regex for it.

What I have are routes like the following

$stateProvider
.state('home', {url:'/', templateUrl:'/template/path.html'})
.state('author', {url:'/{username:[regex-to-match-@username-here]}'})
.state('info', {url:'/:slug', templateUrl:'/template/path.html'})
.state('entry', {url:'/:type/:slug', templateUrl:'/template/path.html'});

I need a bit of regex for the 'author' route that will match @usernames. Currently, everything I try is caught by the 'entry' route.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about angularjs