新手问题 这个正则怎么写?

u1453357893 · August 24, 2016 · Last by u1453357893 replied at August 24, 2016 · 1528 hits

输入 content 的时候不让输入中/英文双引号,这个正则怎么写?

这个试一下:

content.match(/(["“])(?:(?!\1).)*\1/)
content = "你好,我说的是\"英文引号\",不是“中文双引号”而已。"
if content =~ /\"|\u{201D}|\u{201C}/
 puts '_'*88+'说了不让用引号,咋就不听呢!'
end
# ________________________________________________________________________________________说了不让用引号,咋就不听呢!
# => nil
You need to Sign in before reply, if you don't have an account, please Sign up first.