Let the URL allow only some characters of regular expressions _ regular expressions
Source: Internet
Author: User
For example, the restriction allows only regular occurrences of the following
A-Z
0-9
http://Matching coherence
https://Matching coherence
/Not two consecutive occurrences
&
%
? Not two consecutive occurrences
= equals sign
-Medium underline
_ Underline
. It's important.
^ ((?: HTTP|HTTPS)://)? ((?! [/?] {2,}) [a-za-z0-9\-._%&=/?]) +$
• Assertion at the beginning of the string
• Reverse Reference 1
◦ Repeat 0 times to 1 times as many matches as possible (greed)
◦ Match with the following regular expression
Match with the following regular expression (this regular expression fails with the substitution of the next regular expression)
Match character "http"
Match with the following regular expression (this regular expression match fails and this collection does not match)
Match character "https"
◦ Matching character "://"
• Reverse Reference 2
◦ Repeat 1 times to infinity, as many matches as possible (greed)
◦ Note: You're quoting yourself backwards. The match will be referred to as the last reverse reference. Repeat the reverse reference iteration.
◦ Negative Forward View
Match a character that appears in the following list "/?"
Between 2 and unlimited times, as many times as possible, giving back as needed (greedy)
◦ matches a character that appears in the following list
A character whose range is between A and Z
A character whose range is between A and Z
A character whose range is between 0 and 9
Character "-"
One character is ". _%&=/?" One of them
• Assertion at the end of the string
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.