我需要在javascript中使用正則表達式模式來匹配下面類型的字符串。與此字符串匹配的正則表達式
E.g. /this/<one or more than one word with hyphen>/<one or more than one word with hyphen>/<one or more than one word with hyphen>/<one or more than one word with hyphen>
所以這個單一的模式應與這兩個字符串:
1. /this/is/single-word
2. /this/is more-than/single/word-patterns/to-be-matched
只有斜槓(/)和「本」在開始的時候是一致的,並且只包含字母。
'test'in beginning?你的意思是'這個'?此外,它看起來像第二個例子不匹配的模式,因爲有一個沒有連字符的單詞的部分。 – JLewkovich
有什麼不同:http://stackoverflow.com/questions/22616534/regex-pattern-to-match-a-type-of-strings – anubhava
@anubhava ...字符串實際上包含連字符而不是空格。我在前面的問題中輸入了錯誤的字符串 –