javascript - Regex pattern to match this string -


this question has answer here:

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-be-matched 

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

try -

^\/this(?:\/[\w\- ]+)+$ 

demo here


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -