JavaScript的正则表达式支持阿鲁巴和巴巴多斯邮政编码
问题描述:
寻找一个正则表达式允许低于2个邮政编码阿鲁巴和巴巴多斯JavaScript的正则表达式支持阿鲁巴和巴巴多斯邮政编码
- Aruba - 0000AW (Only 6 characters are allowed in the format 4
digit(only 0) at the beginning and 2 characters (only A and W) at the
end)
- Barbados - BB15094 (Only 7 characters are allowed in the format 2
characters(only B) at the beginning and 4 digits (0 t0 9) at the end)
有人可以帮我拿到这个正则表达式?
我想巴巴多斯 - /^[Bb]{2}?[0-9]{5}$/
和阿鲁巴 - /^[0]{4}?[Aa]{1}[Ww]{1}$/
。
30分钟[花在这里](https://regexone.com/)将教你如何写下它。 –
@WiktorStribiżew感谢thids链接。 对于巴巴多斯我试过/^[Bb] [Bb]?[0-9] [0-9] [0-9] [0-9] [0-9] $ /,它的工作原理。但是我不想重复[0-9] 5次。能否请你帮忙 ? – Kenta
您错过了[*第6课:抓住一些zzz的*](https://regexone.com/lesson/repeating_characters)。 –