diff --git a/lib/ronin/support/text/patterns/numeric.rb b/lib/ronin/support/text/patterns/numeric.rb index 9fbbb078..42d7257d 100644 --- a/lib/ronin/support/text/patterns/numeric.rb +++ b/lib/ronin/support/text/patterns/numeric.rb @@ -32,6 +32,11 @@ module Patterns # @since 1.0.0 NUMBER = /[0-9]+/ + # Regular expression for finding all floating point numbers in text. + # + # @since 1.2.0 + FLOATING_POINT_NUMBER = /\d+\.\d+(?:e[+-]?\d+)?/ + # Regular expression for finding a octal bytes (0 - 377) # # @since 1.2.0 diff --git a/spec/text/patterns/numeric_spec.rb b/spec/text/patterns/numeric_spec.rb index cb391a76..dc3a9597 100644 --- a/spec/text/patterns/numeric_spec.rb +++ b/spec/text/patterns/numeric_spec.rb @@ -13,6 +13,34 @@ end end + describe "FLOATING_POINT_NUMBER" do + subject { described_class::FLOATING_POINT_NUMBER } + + it "must match 0.5" do + expect('0.5').to fully_match(subject) + end + + it "must match 0.1234" do + expect('0.1234').to fully_match(subject) + end + + it "must match 1234.0" do + expect('1234.0').to fully_match(subject) + end + + it "must match 1.0e10" do + expect('1.0e10').to fully_match(subject) + end + + it "must match 1.0e+10" do + expect('1.0e+10').to fully_match(subject) + end + + it "must match 1.0e-10" do + expect('1.0e-10').to fully_match(subject) + end + end + describe "OCTAL_BYTE" do subject { described_class::OCTAL_BYTE }