新手问题 正则表达式 ?!$ 是什么意思

Mr_watermelon · May 13, 2017 · Last by billy replied at May 17, 2017 · 3034 hits

对于这行代码
decimal.gsub!(/\d{3}(?!$)/,'\0,')

请问 ?!$ 是什么意思啊

Negative Lookahead

?!$ 表示不以某结尾的意思,结合 /\d{3}(?!$)/ 来看表示不是以仅 3 个数字结尾的字符串,说简单点就是匹配大于 3 个数字字符的串

Reply to wootaw

谢谢了!

翻成中文就是:什么?不要钱?

You need to Sign in before reply, if you don't have an account, please Sign up first.