Converting shell wildcards to regex

后端 未结 3 770
死守一世寂寞
死守一世寂寞 2020-12-16 21:01

I want to search for titles using shell wildcards like *.js, *.*.* etc. in js. The thing is I loop through a list of titles and I need to filter th

3条回答
  •  时光说笑
    2020-12-16 21:20

    This should be pretty close.

    yourVar.match(/.*\.js$/i)
    

    meaning

    • beginning of string is any character sequence .*
    • followed by .js in the end \.js$
    • do this case insensitive /i

提交回复
热议问题