我正在嘗試使用正則表達式獲得以下條件邏輯。if (text starts with +61) { if (text after +61 is 1800) { // then match 6 digits after 1800. So, the regex until here should be +611800 and then 6 digits } else { // match 9 digits after +61 }}我閱讀了如何編寫條件正則表達式。但是,我被下面的正則表達式困住了^\+61((?=1800)\d{6}|\d{9})$上面的正則表達式失敗了,但它必須成功+611800123456(這必須成功)以下文本通過了正則表達式測試,但它必須失敗+61180012345(這必須失敗)這是我在 regexr 網站中的測試。https://regexr.com/5ia2e
正則表達式中的條件邏輯
泛舟湖上清波郎朗
2023-11-12 15:08:19