Class: Regexp
Overview
Constant Summary collapse
- WORD =
Regular expression for finding words
/[A-Za-z][A-Za-z'\-\.]*[A-Za-z]/
- OCTET =
Regular expression for finding a decimal octet (0 - 255)
/25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9]/
- MAC =
Regular expression for finding MAC addresses in text
/[0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5}/
- IPv4 =
A regular expression for matching IPv4 Addresses.
/#{OCTET}(?:\.#{OCTET}){3}(?:\/\d{1,2})?/
- IPv6 =
A regular expression for matching IPv6 Addresses.
union( /(?:[0-9a-f]{1,4}:){6}#{IPv4}/, /(?:[0-9a-f]{1,4}:){5}[0-9a-f]{1,4}:#{IPv4}/, /(?:[0-9a-f]{1,4}:){5}:[0-9a-f]{1,4}:#{IPv4}/, /(?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,4}:#{IPv4}/, /(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,3}:#{IPv4}/, /(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,2}:#{IPv4}/, /(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,1}:#{IPv4}/, /:(?::[0-9a-f]{1,4}){1,5}:#{IPv4}/, /(?:(?:[0-9a-f]{1,4}:){1,5}|:):#{IPv4}/, /(?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,6}(?:\/\d{1,3})?/, /(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}(?:\/\d{1,3})?/, /(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}(?:\/\d{1,3})?/, /(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}(?:\/\d{1,3})?/, /(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}(?:\/\d{1,3})?/, /(?:[0-9a-f]{1,4}:){1,6}(?::[0-9a-f]{1,4}){1,1}(?:\/\d{1,3})?/, /[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}(?:\/\d{1,3})?/, /:(?::[0-9a-f]{1,4}){1,7}(?:\/\d{1,3})?/, /(?:(?:[0-9a-f]{1,4}:){1,7}|:):(?:\/\d{1,3})?/ )
- IP =
A regular expression for matching IP Addresses.
/#{IPv4}|#{IPv6}/
- HOST_NAME =
Regular expression used to find host-names in text
/(?:[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+)*\.)+(?:#{union(Resolv::TLDS)})/i
- USER_NAME =
Regular expression to match a word in the username of an email address
/[A-Za-z](?:[A-Za-z0-9]*[\._-])*[A-Za-z0-9]+/
- EMAIL_ADDR =
Regular expression to find email addresses in text
/#{USER_NAME}\@#{HOST_NAME}/
- PHONE_NUMBER =
Regular expression to find phone numbers in text
/(?:\d[ \-\.]?)?(?:\d{3}[ \-\.]?)?\d{3}[ \-\.]?\d{4}(?:x\d+)?/
- DELIM =
Regular expression to find deliminators in text
/[;&\n\r]/
- IDENTIFIER =
Regular expression to find identifier in text
/[_]*[a-zA-Z]+[a-zA-Z0-9_-]*/
- FILE_EXT =
Regular expression to find File extensions in text
/(?:\.[A-Za-z0-9]+)+/
- FILE_NAME =
Regular expression to find File names in text
/(?:[^\/\\\. ]|\\[\/\\ ])+/
- FILE =
Regular expression to find Files in text
/#{FILE_NAME}(?:#{FILE_EXT})?/
- DIRECTORY =
Regular expression to find Directory names in text
/(?:\.\.|\.|#{FILE})/
- RELATIVE_UNIX_PATH =
Regular expression to find local UNIX Paths in text
/(?:#{DIRECTORY}\/)+#{DIRECTORY}\/?/
- ABSOLUTE_UNIX_PATH =
Regular expression to find absolute UNIX Paths in text
/(?:\/#{FILE})+\/?/
- UNIX_PATH =
Regular expression to find UNIX Paths in text
/#{ABSOLUTE_UNIX_PATH}|#{RELATIVE_UNIX_PATH}/
- RELATIVE_WINDOWS_PATH =
Regular expression to find local Windows Paths in text
/(?:#{DIRECTORY}\\)+#{DIRECTORY}\\?/
- ABSOLUTE_WINDOWS_PATH =
Regular expression to find absolute Windows Paths in text
/[A-Za-z]:(?:\\#{FILE})+\\?/
- WINDOWS_PATH =
Regular expression to find Windows Paths in text
/#{ABSOLUTE_WINDOWS_PATH}|#{RELATIVE_WINDOWS_PATH}/
- RELATIVE_PATH =
Regular expression to find local Paths in text
/#{RELATIVE_UNIX_PATH}|#{RELATIVE_WINDOWS_PATH}/
- ABSOLUTE_PATH =
Regular expression to find absolute Paths in text
/#{ABSOLUTE_UNIX_PATH}|#{ABSOLUTE_WINDOWS_PATH}/
- PATH =
Regular expression to find Paths in text
/#{UNIX_PATH}|#{WINDOWS_PATH}/