Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在java中我只是简单地制作:
boolean match = string.matches("\\d{2}-\\d{2}");
我如何在javascript中制作这个?
在 JavaScript 中:
var inputString = '22-34'; var pattern = /\d{2}-\d{2}/; var match = pattern.test(inputString); // match will equal true
MDN 正则表达式参考文档