Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

rails where regex

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

regex in rails

Model.where("column ~* ?", ''^Ad{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 ~* ?", '^Ad{4}$')
Comment

PREVIOUS NEXT
Code Example
Ruby :: date time string to time in rails 
Ruby :: if rails.env.development 
Ruby :: ruby csv parse 
Ruby :: ruby find method 
Ruby :: Ruby ruby-2.6.3 is present on the following stacks: heroku 16 
Ruby :: ruby change directory 
Ruby :: ruby 
Ruby :: rails generate rake task 
Ruby :: ruby hello 
Ruby :: rails image tag data attribute 
Ruby :: Seconds to HH:MM in Ruby 
Ruby :: heroku run rails 
Ruby :: how to use multiple ruby version in mac as per project 
Ruby :: require multiple files ruby 
Ruby :: create table index unique rails 
Ruby :: ffi gem error mac 
Ruby :: ruby check if path is a directory 
Ruby :: rails change database connection 
Ruby :: get single hash key ruby 
Ruby :: sequel ruby alias table 
Ruby :: mobile money flutterwave payment 
Ruby :: ruby block_given? method 
Ruby :: diff between .. and ... in ruby 
Ruby :: Or even multiple scope parameters. For example, making sure that a teacher can only be on the schedule once per semester for a particular class. 
Ruby :: ruby basic arithmetic 
Ruby :: does destroy retrurn in ruby 
R :: how to count the number of NA in r 
R :: r list append 
R :: r set dataframe column names 
R :: sort dataframe dplyr 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =