[英]How to express in JS regex any of “iPhone10,3”, “iPhone10,6”, “iPhone11,2”, “iPhone11,4”, “iPhone11,8”
我想處理iOS內部名稱。 我想在JS中檢查const type
是否等於
"iPhone10,3", "iPhone10,6", "iPhone11,2", "iPhone11,4", "iPhone11,8"
。
我想用最短的方式表達這一點,但這有點復雜。
是
type.match(/^iPhone(10\,[36]|11\,\d)$/)
最短的?
如果只允許這5個特定的可能值,則還應限制iPhone 11的版本轉換:
^iPhone(10,[36]|11,[248])$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.