How to capture numbers in specific range with floating point?

Call me Walter

The question is straight forward. I have some numbers, and I try to match numbers in range from 0 to 110. Let's say we have five numbers:

99.9

108.712718

110

110.2

9

Here I need to match all except fourth. I tried a lot. Capturing group, positive/negative lookahead and so on. Nothing works for me. It's easy without floating point, but here I struggling so much.

P.S. I' doing it with Python.

horcrux

Something like this should work:

(?<!\.)\b0*(?:(?:\d\d?|10\d)(?:\.\d+)?|110(?:\.0+)?)\b(?!\.\d)
  • (?<!\.) means "not preceded by a dot (\.)"
  • \b is the word boundary
  • 0* means "preceded by zero or more 0"
  • (\d\d?|10\d) means "one digit followed by another optional digit (\d\d?) or 10 followed by any digit"
  • then an optional "dot and one or more digits" ((\.\d+)?)
  • the last two points are in "or" with the simple number 110 with one or more 0 after a dot ((?:\.0+)?)
  • another word boundary for matching the end of the number
  • and finally (?!\.\d), which means "not followed by a dot and a digit"

See here a demo.

P.S. If you are matching the correspondence of the whole string, negative lookahead and lookbehind are useless.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I generate a range of random floating point numbers in Julia?

compress floating point numbers with specified range and precision

how to input floating point numbers

Bash issue with floating point numbers in specific format

How to convert pcm samples in byte array as floating point numbers in the range -1.0 to 1.0 and back?

Can I group floating point numbers by range in MongoDB?

How to increment floating point numbers by 1?

How to convert dataframe dates into floating point numbers?

How to sum of arrays of floating point numbers

How to get the average of two floating point numbers

How to print floating point numbers from assembly?

How are floating point numbers stored inside the CPU?

Understanding how these floating point numbers work?

PROLOG - How to round decimals of floating point numbers?

How to substract floating point numbers with high precision

Floating point range reduction

Is there a Microsoft-specific (for Microsoft compiler) data type for floating point numbers

Floating point numbers in bash

Formatting Floating Point Numbers

Extreme Floating Point Numbers

Classifiers on floating point numbers

Set of floating point numbers

product of floating point numbers

Negative Floating Point Numbers

Range analysis of floating point values?

How to find shortest decimal number between two floating point numbers

How can I pass floating point numbers as template parameters?

Python - How to add zeros to floating point numbers between -1 and 1

How does casting from integers to floating-point numbers work?