Theres the escapeRegExp function that is very handy on these situations.

Your going to use just the '*' pattern you could do something link:

var matcher = new RegExp('^' +
'/user/name/*'.escapeRegExp().replace(/\\\*/g, '[^\/]+') + '$')

just make sure about the number of '\', im not sure, havent tested this.
Hope it helps.

--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces


On Fri, Jan 22, 2010 at 7:58 PM, Eneko Alonso <[email protected]>wrote:

> I´m looking for a way of matching strings, similar to regular expresions,
> but making it easy for the user.
>
> I want the user to be able to enter a path like
>
> /user/name/*
>
> and have that path to match with any path that starts with /user/name/
> like:
> /user/name/
> /user/name/pics
> /user/name/comments
> etc.
>
> So given the second url, I need to see if it matches the first one (the one
> with the asterisk).
>
> Any suggestions? Are there any Mootools functions out there that may help?
>
>
> Thanks a lot
>

Reply via email to