Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一大块 HTML,其中包含多个带有空格的 URL。如何使用 Regex 将 URL 中出现的任何空格替换为“%20”。好消息是所有的 URL 都以“.pdf”结尾。
寻找可以在 BBedit/Text Wrangler 甚至 PHP 中运行的东西。
例子:http://www.site-name.com/dir/file name here.pdf
http://www.site-name.com/dir/file name here.pdf
需要退货:http://www.site-name.com/dir/file%20name%20here.pdf
http://www.site-name.com/dir/file%20name%20here.pdf
您可以使用PHP 中的urlencode代替 Regex来实现此目的,从而为您转义 url。类似于JavaScript 中的encodeURI。