Depends what you're trying to do. For a start, the number must be in a string. Secondly, the way you've presented your example suggests to me that you have an array. Since RegExp wants text input, you'd have to Join() your array. And that will probably be leading you away from anywhere that I can guess you might want to be.
What I'm trying to do is using the regular expression to search for a decimal number in a certain range. For instance 1234.12. I would like to look for numbers that are about the +.1 to -.1 range. I wonder if you can find 1234.13, 1234.14, 1234.15, 1234.19, 1234.20. Something like that. If you could help me out, I would really appreciate that.
How are the numbers stored, and in what format? If these numbers are in a database, stored as type Float (or Single/Double), then you can use a SQL statement such as:
Select * From Table Where Number is between 1234.02 and 1234.22
Doing this with regular expressions is much harder, as you need to account for number wrap (if number is 2.02, then range is 1.92 - 2.12). So to do the comparison with regular expressions, you need check for 3 different conditions and use a different regular expression for each.
Hi,
Create a class Class1 with a constructor in which you pass the the range you want.
Add method like bool CheckInRange (string expr) in which you do:
-use regular expresion object to match the expr with a decimal number.
-if no match return false
-if match then extraxt the decimal number and check if it is in the range.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.