我尝试使用正则表达式来实现firebase安全规则以检查它是否是有效的URL。以下是网址的一些示例:
https://firebasestorage.googleapis.com/andTheRestIsJustThePartAfterIUploadedIntoFirebaseStorage
我用这个正则表达式检查:
"imageURL": {
".validate": "newData.val().matches(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/)"
}
但是,我在Line 26: Invalid escape: '\+'.
有什么想法吗?
答案 0 :(得分:1)
没有必要在regex class
中转义meci = driver.find_elements_by_class_name('KambiBC-event-result__match')
for items in meci:
scor = meci.find_element_by_class_name('KambiBC-event-result__points')
print (scor.text)
,而是使用它:
+
我在你的模式中看到了另一个语法错误,某些角色应该是不应该转义的,你的模式应该是这样的:
[-+=&;%@.\w_]
但是我不确定你的模式的逻辑,我可以建议阅读这个有关Firebase Security Rules Regular Expressions的更多信息