diff --git a/lib/ronin/support/text/patterns/numeric.rb b/lib/ronin/support/text/patterns/numeric.rb index 3f19a491..deea2736 100644 --- a/lib/ronin/support/text/patterns/numeric.rb +++ b/lib/ronin/support/text/patterns/numeric.rb @@ -32,10 +32,15 @@ module Patterns # @since 1.0.0 NUMBER = /[0-9]+/ + # Regular expression for finding a decimal bytes (0 - 255) + # + # @since 1.2.0 + DECIMAL_BYTE = /(?<=[^\d]|^)(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])(?=[^\d]|$)/ + # Regular expression for finding a decimal octet (0 - 255) # # @since 0.4.0 - DECIMAL_OCTET = /(?<=[^\d]|^)(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])(?=[^\d]|$)/ + DECIMAL_OCTET = DECIMAL_BYTE # Regular expression for finding all hexadecimal numbers in text. # diff --git a/spec/text/patterns/numeric_spec.rb b/spec/text/patterns/numeric_spec.rb index 80b41467..6199942d 100644 --- a/spec/text/patterns/numeric_spec.rb +++ b/spec/text/patterns/numeric_spec.rb @@ -13,8 +13,8 @@ end end - describe "DECIMAL_OCTET" do - subject { described_class::DECIMAL_OCTET } + describe "DECIMAL_BYTE" do + subject { described_class::DECIMAL_BYTE } it "must match 0 - 255" do numbers = (0..255).map(&:to_s) @@ -27,6 +27,14 @@ end end + describe "DECIMAL_OCTET" do + subject { described_class::DECIMAL_OCTET } + + it "must be an alias for DECIMAL_BYTE" do + expect(subject).to be(described_class::DECIMAL_BYTE) + end + end + describe "HEX_NUMBER" do subject { described_class::HEX_NUMBER }