javascript url-safe filename-safe string

前端 未结 4 817
误落风尘
误落风尘 2021-01-30 10:08

Looking for a regex/replace function to take a user inputted string say, \"John Smith\'s Cool Page\" and return a filename/url safe string like \"john_smith_s_cool_page.html\",

4条回答
  •  粉色の甜心
    2021-01-30 10:50

    I think your requirement is to replaces white spaces and aphostophy `s with _ and append the .html at the end try to find such regex.

    refer

    http://www.regular-expressions.info/javascriptexample.html

提交回复
热议问题