Skip to content

Commit

Permalink
Allow Text::Patterns::NUMBER to match e exponents.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Dec 12, 2024
1 parent 440f9cb commit 548c192
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ronin/support/text/patterns/numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Patterns
# Regular expression for finding all numbers in text.
#
# @since 1.0.0
NUMBER = /(?:-)?[0-9]+/
NUMBER = /(?:-)?[0-9]+(?:e[+-]?\d+)?/

# Regular expression for finding all floating point numbers in text.
#
Expand Down
12 changes: 12 additions & 0 deletions spec/text/patterns/numeric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
it "must match negative numbers" do
expect("-#{number}").to fully_match(subject)
end

it "must match numbers with an 'e' exponent suffix" do
expect("1e10").to fully_match(subject)
end

it "must match numbers with an 'e+' exponent suffix" do
expect("1e+10").to fully_match(subject)
end

it "must match numbers with an 'e-' exponent suffix" do
expect("1e-10").to fully_match(subject)
end
end

describe "FLOAT" do
Expand Down

0 comments on commit 548c192

Please sign in to comment.