How to add multiline option on RegularExpression attribute?

后端 未结 3 350
面向向阳花
面向向阳花 2021-01-18 19:37

I am using:

[RegularExpression(@\"^(\"\"|\\[)?[a-zA-Z0-9\']{1,125}(\"\"|\\])?$\")]

to make sure each line of a multiline textbox is properl

3条回答
  •  伪装坚强ぢ
    2021-01-18 20:06

    This is how you would do it with Regex, basically not relying on multiline flag or attribute, instead you explicitly define the regex to allow new lines but the same pattern needs to follow

    [RegularExpression(@"^(""|\[)?[a-zA-Z0-9']{1,125}(""|\])?(?:\r?\n(""|\[)?[a-zA-Z0-9']{1,125}(""|\])?)*$")]
    

提交回复
热议问题