开发者

Regular expression for unicode URL

开发者 https://www.devze.com 2023-03-05 06:27 出处:网络
There is a regex for URL but it does not support unicode characters. ^(ht|f)tp(s?)\\:\\/\\/[0-9a-zA-Z]([-.\\w]*[0-开发者_Go百科9a-zA-Z])*(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\,\\\'\\/\\\\\\+&

There is a regex for URL but it does not support unicode characters.

^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-开发者_Go百科9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?

I want to use it in both javascript and C#


Replace every occurrences of a-zA-Z by \pL.

Thanks to @Lesley:

Unicode properties are not available in javascript, we have to use a package like regexp.


As you are using Unicode characters I think that you want to get non english language (like Arabic, hebrew or persian....) so just chage the are from a-z A-Z to ا-ی or other equivalents

0

精彩评论

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