2017-10-05 70 views
0

我正在檢查用戶的任何角色是否是文檔的允許角色的一部分。以下應匹配,因爲用戶是管理員+ 編輯,以及後允許由出版商+ 編輯閱讀:正則表達式不匹配 - Firestore

service cloud.firestore { 
    match /databases/{database}/documents { 

    match /group/{groupId} { 
     match /posts/{postId} { 
     allow read: if 'admin,editor'.matches('((,|^)(publisher|editor)(,|$))'); 
     } 
    } 

    } 
} 

下面是一個正則表達式測試儀的工作吧:https://regex101.com/r/bDXMg3/2/

但這不匹配, 有任何想法嗎?

回答

0

我們的文檔可能會更清晰,但它看起來像整個字符串需要匹配。試試(.*,|^)(publisher|editor)(,.*|$)