我的正则表达式:
/*
+-------------+
| |
| |
| |
| |
| |
| |
+-------------+
The IMAGE MUST BE SQUARE
*/
class roundImageView: UIImageView {
override init(frame: CGRect) {
// 1. setup any properties here
// 2. call super.init(frame:)
super.init(frame: frame)
// 3. Setup view from .xib file
}
required init?(coder aDecoder: NSCoder) {
// 1. setup any properties here
// 2. call super.init(coder:)
super.init(coder: aDecoder)
// 3. Setup view from .xib file
}
override func layoutSubviews() {
super.layoutSubviews()
self.layer.borderWidth = 1
self.layer.masksToBounds = false
self.layer.borderColor = UIColor.white.cgColor
self.layer.cornerRadius = self.frame.size.width/2
self.clipsToBounds = true
}
}
到目前为止,这个正则表达式匹配字符串中的url。但是当网址包含西里尔字母或其他语言字符时,这会失败。
答案 0 :(得分:0)
"(^(ht|f)tp(s?)://[0-9a-zA-Z\\p{L}][-.\\w\\p{L}]*(:[0-9])*(/?)([a-zA-Z0-9-.?,:'/\\\\+=&%$#_\\[\\]@!()*;~\\p{L}]*)?$)"
这适用于包含西里尔字符的网址