开发者

How do I match japanese characters using IDN regex?

开发者 https://www.devze.com 2023-01-07 05:59 出处:网络
Based on this post link text i came up with a regex for javascript \\b(([\\w-]+:\\/\\/?|[\\w\\d]+[.])?[^\\s()<>]+[.](?:\\([\\w\\d]+\\)|([^`!()\\[\\]{};:\'\".,<>?«»“”‘’\\s]|\\/)))

Based on this post link text

i came up with a regex for javascript

\b(([\w-]+:\/\/?|[\w\d]+[.])?[^\s()<>]+[.](?:\([\w\d]+\)|([^`!()\[\]{};:'".,<>?«»“”‘’\s]|\/)))

this one matches urls like

  • http://google.com
  • http://www.google.com
  • google.com

It fails for google, but when I used japanese characters like 功功.jp it fails.

These match. What should I change so that 功功.jp also matches.


Very slight modification made here has it working for me:

/(([\w-]+:\/\/?|[\w\d]+[.])?[^\s()<>]+[.](?:\([\w\d]+\)|([^`!()\[\]{};:'\".,<>?«»“”‘’\s]|\/)+))/
0

精彩评论

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