URL 安全字符正则表达式将允许 UTF-8 重音!

Moh*_*mad 5 regex url coldfusion url-rewriting

我正在寻找一个在rereplace()函数中使用的正则表达式模式,该模式将保留 URL 安全字符,但包含带重音符号的 UTF-8 字符。例如: \xc3\xa7\xc3\xa3

\n\n

诸如此类。url = rereplace(local.url, "pattern")我更喜欢仅使用 ColdFusion 的解决方案,但我也愿意使用 Java,因为它很容易与 CF 集成。

\n\n

我的 URL 模式将如下所示:/posts/[postId]/[title-with-accents-like-\xc3\xa7-and-\xc3\xa3]

\n

Moh*_*mad 0

这可以通过使用 匹配字母数字字符来完成\w

rereplace(string, "[^\w]", "", "all")

请参阅此答案以供参考。