哪些字符在URL中有效? [英] What characters are valid in a URL?

查看:106
本文介绍了哪些字符在URL中有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

哪些字符使网址无效? 试图删除大字符串的非URL部分。我发现的大多数正则表达式都像 [A-Za-z0-9 -_。!〜*'()] ,但url还可以包含更多的东西。像 http://127.0.0.1:8080/test?v=123#this 例如



是一个有效的URL的最新字符?



编辑:



他们似乎是:


A-Za-z0-9 -._〜:/?#[] @!$&'()* +,; =和%其次是十六进制值


解决方案

所有血腥细节都可以在当前的RFC中找到话题: RFC 3986(统一资源标识符(URI):通用语法)



基于此相关答案,您正在查看如下所示的列表: AZ az 0-9 - _ / [] @ $ & ' * + ; = 。其他一切必须网址编码。而且,其中一些字符只能存在于URI中的特定位置,RFC具有所有这些特性。

Possible Duplicate:
Which characters make a url invalid?

I'm trying to remove the non-URL part of a big string. Most of the regexes I found are like [A-Za-z0-9-_.!~*'()], but there are more things that can a url contain. Like http://127.0.0.1:8080/test?v=123#this for example

So what are the latest characters for a valid URL?

EDIT:

They seem to be:

A-Za-z0-9-._~:/?#[]@!$&'()*+,;= and % followed by hex value

解决方案

All the gory details can be found in the current RFC on the topic: RFC 3986 (Uniform Resource Identifier (URI): Generic Syntax)

Based on this related answer, you are looking at a list that looks like: A-Z, a-z, 0-9, -, ., _, ~, :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, and =. Everything else must be url-encoded. Also, some of these characters can only exist in very specific spots in a URI, the RFC has all of these specifics.

这篇关于哪些字符在URL中有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆