常规URL表达式comprension [重复]

问题描述 投票:-4回答:1

这个问题在这里已有答案:

我试图找出我在PHP中使用的这个正则表达式,但我是一个非常好的,所以对我来说非常困难。你能解释一下这个正则表达式的作用吗?

/(?:https?:\/\/)?(?:[a-zA-Z0-9.-]+?\.(?:[a-zA-Z])|\d+\.\d+\.\d+\.\d+)/

非常感谢你!

php regex url
1个回答
0
投票
Brackets

[0-9] - It matches any decimal digit from 0 through 9.
[a-z] - It matches any character from lower-case a through lowercase z.
[A-Z] - It matches any character from uppercase A through uppercase Z.
[a-Z] - It matches any character from lowercase a through uppercase Z.

Quantifiers

p+ - It matches any string containing at least one p. 
p* - It matches any string containing zero or more p's.     
p? - It matches any string containing zero or one p's.  
p{N} - It matches any string containing a sequence of N p's     
p{2,3} - It matches any string containing a sequence of two or three p's.   
p{2, } - It matches any string containing a sequence of at least two p's.
p$ - It matches any string with p at the end of it.
^p - It matches any string with p at the beginning of it.

Expression & Description

[[:alpha:]] - It matches any string containing alphabetic characters aA through zZ. 
[[:digit:]] - It matches any string containing numerical digits 0 through 9.
[[:alnum:]] - It matches any string containing alphanumeric characters aA through zZ and 0 through 9.   
[[:space:]] - It matches any string containing a space.

欲了解更多信息,请访问:Regex

© www.soinside.com 2019 - 2024. All rights reserved.