Class: Regexp

Inherits:
Object show all
Defined in:
lib/ronin/extensions/regexp.rb

Overview

Since:

  • 0.3.0

Constant Summary collapse

WORD =

Regular expression for finding words

Since:

  • 0.5.0

/[A-Za-z][A-Za-z'\-\.]*[A-Za-z]/
OCTET =

Regular expression for finding a decimal octet (0 - 255)

Since:

  • 0.4.0

/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

Since:

  • 0.3.0

/[0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5}/
IPv4 =

A regular expression for matching IPv4 Addresses.

Since:

  • 0.3.0

/#{OCTET}(?:\.#{OCTET}){3}(?:\/\d{1,2})?/
IPv6 =

A regular expression for matching IPv6 Addresses.

Since:

  • 0.3.0

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.

Since:

  • 0.3.0

/#{IPv4}|#{IPv6}/
HOST_NAME =

Regular expression used to find host-names in text

Since:

  • 0.3.0

/(?:[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

Since:

  • 0.3.0

/[A-Za-z](?:[A-Za-z0-9]*[\._-])*[A-Za-z0-9]+/
EMAIL_ADDR =

Regular expression to find email addresses in text

Since:

  • 0.3.0

/#{USER_NAME}\@#{HOST_NAME}/
PHONE_NUMBER =

Regular expression to find phone numbers in text

Since:

  • 0.5.0

/(?:\d[ \-\.]?)?(?:\d{3}[ \-\.]?)?\d{3}[ \-\.]?\d{4}(?:x\d+)?/
DELIM =

Regular expression to find deliminators in text

Since:

  • 0.4.0

/[;&\n\r]/
IDENTIFIER =

Regular expression to find identifier in text

Since:

  • 0.4.0

/[_]*[a-zA-Z]+[a-zA-Z0-9_-]*/
FILE_EXT =

Regular expression to find File extensions in text

Since:

  • 0.4.0

/(?:\.[A-Za-z0-9]+)+/
FILE_NAME =

Regular expression to find File names in text

Since:

  • 0.4.0

/(?:[^\/\\\. ]|\\[\/\\ ])+/
FILE =

Regular expression to find Files in text

Since:

  • 0.4.0

/#{FILE_NAME}(?:#{FILE_EXT})?/
DIRECTORY =

Regular expression to find Directory names in text

Since:

  • 0.4.0

/(?:\.\.|\.|#{FILE})/
RELATIVE_UNIX_PATH =

Regular expression to find local UNIX Paths in text

Since:

  • 0.4.0

/(?:#{DIRECTORY}\/)+#{DIRECTORY}\/?/
ABSOLUTE_UNIX_PATH =

Regular expression to find absolute UNIX Paths in text

Since:

  • 0.4.0

/(?:\/#{FILE})+\/?/
UNIX_PATH =

Regular expression to find UNIX Paths in text

Since:

  • 0.4.0

/#{ABSOLUTE_UNIX_PATH}|#{RELATIVE_UNIX_PATH}/
RELATIVE_WINDOWS_PATH =

Regular expression to find local Windows Paths in text

Since:

  • 0.4.0

/(?:#{DIRECTORY}\\)+#{DIRECTORY}\\?/
ABSOLUTE_WINDOWS_PATH =

Regular expression to find absolute Windows Paths in text

Since:

  • 0.4.0

/[A-Za-z]:(?:\\#{FILE})+\\?/
WINDOWS_PATH =

Regular expression to find Windows Paths in text

Since:

  • 0.4.0

/#{ABSOLUTE_WINDOWS_PATH}|#{RELATIVE_WINDOWS_PATH}/
RELATIVE_PATH =

Regular expression to find local Paths in text

Since:

  • 0.4.0

/#{RELATIVE_UNIX_PATH}|#{RELATIVE_WINDOWS_PATH}/
ABSOLUTE_PATH =

Regular expression to find absolute Paths in text

Since:

  • 0.4.0

/#{ABSOLUTE_UNIX_PATH}|#{ABSOLUTE_WINDOWS_PATH}/
PATH =

Regular expression to find Paths in text

Since:

  • 0.4.0

/#{UNIX_PATH}|#{WINDOWS_PATH}/