开发者

URL safe characters RegEx that will allow UTF-8 accents!

开发者 https://www.devze.com 2023-03-14 01:31 出处:网络
I\'m looking for a RegEx pattern to use in a rereplace() function that will keep URL safe characters, but include UTF-8 characters with accents. For example:ç and ã.

I'm looking for a RegEx pattern to use in a rereplace() function that will keep URL safe characters, but include UTF-8 characters with accents. For example: ç and ã.

Something like: url = rereplace(local.url, "pattern") etc. I pref开发者_开发技巧er a ColdFusion only solution, but I'm open to using Java too since it's so easy to integrate with CF.

My URL pattern will look like: /posts/[postId]/[title-with-accents-like-ç-and-ã]


I don't know what language you are using. Perl has some utf8 matching, see for example Tatsuhiko Miyagawa's URI::Find::UTF8


This can be done by matching alpha numeric characters using \w.

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

See this answer for reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消