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.
我需要在字符串中找到 4 个连续数字的第一次出现(如果存在)。
例如:
你好6326 -> 6326 Tomo3753 行 -> 3753 23谢谢->(无) 1121 -> 1121
我知道我必须使用正则表达式,我尝试了不同的解决方案但没有运气。
/\d{4}/g
样本:
var str:String = "Hello6326 -> 6326 Tomo3753rrow -> 3753 23Thankyou -> nothing 1121 -> 1121"; var res:Array = str.match(/\d{4}/g); trace(res);
输出:
6326,6326,3753,3753,1121,1121