Skip to content

Commit

Permalink
Added Text::Patterns::FLOATING_POINT_NUMBER (closes #553).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Dec 11, 2024
1 parent a7cde48 commit 9b546cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ronin/support/text/patterns/numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions spec/text/patterns/numeric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 9b546cc

Please sign in to comment.