我有一个用户模型,我有简要介绍"介绍"我的用户模型中用户的类型是字符串,如下所示。
VALID_INTRO_REGEX = /\A[a-zA-Z\.\,]+(?: [a-zA-Z\.\,]+)*\z/
validates :intro, presence: true, length: { maximum: 255 },
format: { with: VALID_INTRO_REGEX, :message => "must contain only letters" }
如何制作满足以下有效和无效语句的正则表达式?
Valid = "Hey everyone! My name is xxxx. I am from XXX. I do this, I do that."
Invalid = "<img src= "
Invalid = "">< img src=x onerror=alert(0);>"