javascript - regex pattern to match a type of strings -


i need match below type of strings using regex pattern in javascript.

e.g. /this/<one or more 1 word hyphen>/<one or more 1 word hyphen>/<one or more 1 word hyphen>/<one or more 1 word hyphen> 

so single pattern should match both these strings:

1. /this/is/single-word 2. /this/is-more-than/single/word-patterns/to-match 

only slash (/) , 'this' string in beginning consistent , contains alphabets.

you can use:

\/this\/[a-za-z ]+\/[a-za-z ]+\/[a-za-z ]+ 

working demo


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -