module RegexData

Constants

VERSION

Public Class Methods

ban_word(data, *args) click to toggle source
# File lib/regex_data.rb, line 36
def self.ban_word data, *args
  ban = args.join("|")
  return data.gsub!(/(#{ban})/, '****')
end
color_code?(data) click to toggle source
# File lib/regex_data.rb, line 20
def self.color_code? data
  if data =~ /rgb\((?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]))\)/
    return true
  else
    return false
  end
end
date?(data) click to toggle source
# File lib/regex_data.rb, line 28
def self.date? data
  if data =~ /^([0]?[1-9]|[1|2][0-9]|[3][0|1])[\.|\-]([0]?[1-9]|[1][0-2])[\.|\-]([0-9]{4}|[0-9]{2})$/
    return true
  else
    return false
  end
end
email?(data) click to toggle source
# File lib/regex_data.rb, line 4
def self.email? data
  if data =~ /^(?:(?:[\w`~!#$%^&*\-=+;:{}'|,?\/]+(?:(?:\.(?:"(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\"|\\\\)*"|[\w`~!#$%^&*\-=+;:{}'|,?\/]+))*\.[\w`~!#$%^&*\-=+;:{}'|,?\/]+)?)|(?:"(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\"|\\\\)+"))@(?:[a-zA-Z\d\-]+(?:\.[a-zA-Z\d\-]+)*|\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])$/
    return true
  else
    return false
  end
end
ip_address_v4?(data) click to toggle source
# File lib/regex_data.rb, line 66
def self.ip_address_v4? data
  if data =~ /\b(?:(?:2(?:[0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9])\.){3}(?:(?:2([0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9]))\b/
    return true
  else
    return false
  end
end
max_length(data, max) click to toggle source
# File lib/regex_data.rb, line 54
def self.max_length data, max
  data.length <= max ? true : false
end
min_length(data, min) click to toggle source
# File lib/regex_data.rb, line 50
def self.min_length data, min
  data.length >= min ? true : false
end
remove_all_spaces(data) click to toggle source
# File lib/regex_data.rb, line 46
def self.remove_all_spaces data
  return  data.gsub(/\s+/, '')
end
remove_empty_line(data) click to toggle source
# File lib/regex_data.rb, line 58
def self.remove_empty_line data
  return data.gsub(/[\n]+/, "\n")
end
remove_extra_space(data) click to toggle source
# File lib/regex_data.rb, line 41
def self.remove_extra_space data
  data.gsub!(/\s+/, ' ')
  return data.gsub(/^\s+|\s+$/, '')
end
remove_html_tag(data) click to toggle source
# File lib/regex_data.rb, line 62
def self.remove_html_tag data
  return data.gsub(/(<(\/?[^\>]+)>)/, "")
end
strong_password?(data) click to toggle source
# File lib/regex_data.rb, line 12
def self.strong_password? data
  if data =~ /^(?!.*(.)\1{1})(?=(.*[\d]){2,})(?=(.*[a-z]){2,})(?=(.*[A-Z]){2,})(?=(.*[@#$%!]){2,})(?:[\da-zA-Z@#$%!]){15,100}$/
    return true
  else
    return false
  end
end
url?(data) click to toggle source
# File lib/regex_data.rb, line 74
def self.url? data
  if data =~ /((?:https\:\/\/)|(?:http\:\/\/)|(?:www\.))?([a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(?:\??)[a-zA-Z0-9\-\._\?\,\'\/\\\+&%\$#\=~]+)/
    return true
  else
    return false
  end
end