Match different url start in regex, javascript -


a bit confused regex.

url string can either '/item/new/url/bla/..' or '/#item/url/bla/bla/..'

i need regex check start of string. in pseudo code can described as:

(both "/#item/" or "/item/" @ start of string should true).test(url) 

/^\/#?item\//.test('/#item/new/url/bla/'); // true /^\/#?item\//.test('/item/new/url/bla/'); // true 

Comments