Query string stanzas

I am looking for the correct regualr expression to check for query string URIs. I have found several answers here or here , but I still doubt in extreme cases when a key or value may be empty. For example, should the following query lines be considered correct?

?&&
?=
?a=
?a=&
?=a
?&=a
0
source share
1 answer

I am looking [...] for the correct regular expression for the [valid] URI query strings.

Of course not a problem. According to RFC 3986, Appendix B , here it is:

^([^#]*)$

- , 3.4 . :

^(%[[:xdigit:]]{2}|[[:print:]])*$

RFC 3986, . RFC , , , . RFC CGI HTTP (., , RFC 3875, . 4.1.7, RFC 2396, . 3.4, RFC 1808, . 2.1, & hellip;).

RFC 7230, 2.4:

, , . [& Hellip;] HTML , . , URI

, W3C. , .

: , . , , . , : ?&& - , ?=a { "": "a" }.

+1

Source: https://habr.com/ru/post/1669940/


All Articles