Created
December 12, 2012 17:59
-
-
Save superscott/4270070 to your computer and use it in GitHub Desktop.
regex
This file contains 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
def self.clean(value, level) | |
case level | |
when 1 #strip html and tags | |
results = Sanitize.clean(value) | |
when 2 #includes level 1, regex to allow symbols | |
leveltwo = Sanitize.clean(value) | |
leveltwo.strip! | |
results = leveltwo.gsub(/[^0-9a-zA-Z\(\)\|\:\/\,\'\.\-\@\_\[\]\&\?\=\s]/, "") | |
when 3 #includes level 1, regex to only allow alphanumeric | |
levelthree = Sanitize.clean(value) | |
levelthree.strip! | |
results = levelthree.gsub(/[^0-9a-zA-Z]/, "") | |
else | |
results = "well that didnt work" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment