regex - Matching numbers with decimals in regular expression -


i want see if number have between 2 other numbers. let's number 0.17. regular expression this: [0.15-0.22]. me on right track?

i think should rethink approach bit. instead of trying match range in regular expression (which doable, not beautiful), try match number you're looking , test if it's in correct range using favorite language. here's python3 session you:

>>> import re >>> a_string = "a number can 0.17 or 0.163 not 0.47 or -1.2!" >>> matches = re.findall(r'(-?[0-9]+\.?[0-9]+)', a_string) >>> print(matches) ['0.17', '0.163', '0.47', '-1.2'] >>> nums = [n n in [float(c) c in matches] if n < 0.22 , n > 0.15] >>> print(nums) [0.17, 0.163] 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -