URL safe characters RegEx that will allow UTF-8 accents!
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.
精彩评论