📜  rails 中的正则表达式 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:35.587000             🧑  作者: Mango

代码示例3
Model.where("column ~* ?", ''^A\d{4}$'')

^ - string start anchor
A - literal "A"
\d+ - one or more digits (0-9)
\d{4} - exactly four digits
$ - string end anchor

Basically, the regex reads "the string should start with an A, followed by 
four digits and then the string should end". The final query line is:

@max_draw = Drawing.where("drawing_number ~* ?", '^A\d{4}$')