-
-
Save cdesch/af70cdc492fef1a19ca8 to your computer and use it in GitHub Desktop.
Rails Regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#regex templates | |
#Subdomain | |
#ensure there are no special characters and the subdomain does not end with a - or _ | |
/^[a-z\d]+([-_][a-z\d]+)*$/i | |
#title | |
/[a-zA-Z0-9.\s]+/i | |
# ensure secret contains at least one number | |
validates_format_of :secret, :with => /[0-9]/, | |
:message => "must contain at least one number" | |
# ensure secret contains at least one upper case | |
validates_format_of :secret, :with => /[A-Z]/, | |
:message => "must contain at least one upper case character" | |
# ensure secret contains at least one lower case | |
validates_format_of :secret, :with => /[a-z]/, | |
:message => "must contain at least one lower case character" | |
#resources | |
http://idiosyncratic-ruby.com/11-regular-extremism.html | |
# RubyMine Replace Regex https://regexr.com/4mqo1 | |
Sample: Faker::Number.between(0, 1000) | |
Target: Faker::Number.between(from: 0, to: 1000) | |
Regex Search: between\(([0-9]), ([0-9]*)\) | |
Replace: between(from: $1, to: $2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment