Reputation: 2205
I'm trying to match any string that is a hashtag of any letters.
I've tested ^#{1}\p{L}+$
on multiple re2 testing sites and they all work fine, but in firestore.rules I get a compilation error:
Error: Compilation errors in firestore.rules:
[E] 33:33 - Unexpected 'p'.
[E] 33:37 - Unexpected '+'.
[E] 36:1 - Unexpected '}'.
Removing \p{L}
gets rid of the error but as far as I can see, that should be valid.
My testing string (the first 3 should match, the rest should not)
#somethingcool
#かんぱい
#señor
#dbudn-asdasd
##burn
kurm
#durm burn
Edit: Here's the rules in place
match /tags/{tagId} {
allow create: if userIs(userId) && isValidTag(tagId)
allow read: if userIs(userId)
}
function isValidTag(tag) {
return tag.matches('^#{1}\p{L}+$') == true
}
Upvotes: 0
Views: 191
Reputation: 317427
Try escaping the backslash with another backslash:
return tag.matches('^#{1}\\p{L}+$') == true
Upvotes: 2