I currently have this regular expression for a whole number with optional decimal to 2 places.
I need to chnage it so that the number has to be greater than 1.
Can anyoen help
Code:[0-9]+(\.[0-9][0-9]?)?
I currently have this regular expression for a whole number with optional decimal to 2 places.
I need to chnage it so that the number has to be greater than 1.
Can anyoen help
Code:[0-9]+(\.[0-9][0-9]?)?
Hey,
Wouldn't you just change the first 0-9 to be 1-9?
However, what is wrong with using the regular expression to bring out the number, and then doing a normal > operation on the result?
Gary
Remember to mark your thread as resolved. Remember to rate posts that help. Hitchhiker's Guide to Getting Help at VB Forums.
ASP.NET Tutorials (updated Feb 1st 2009) ASP.NET FAQs (updated July 17th 2011)
Free Stuff: WebsiteSpark|DreamSpark|BizSpark|eBooks
Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib
Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express
Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings
ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm
Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C#
My Blog - View my MCP Certifications
Hi Gep, Thats the first thing I tried mate but that means no 0's would be allowed before the decimal.
so 12.58 would pass but 10.58 wouldnt.
I wanted to have this all done through the same regular expression validator ideally so I coudl avoid postback.
Possibly something like [1-9][0-9]+(\.[0-9][0-9]?)?
Ah, so you are doing validation on the client...
Couple of options, Range Validator, or a custom validator.
Yes, your last option should do it, or at least get you closer. The only problem being whether you need a number higher than 99?
Gary
Remember to mark your thread as resolved. Remember to rate posts that help. Hitchhiker's Guide to Getting Help at VB Forums.
ASP.NET Tutorials (updated Feb 1st 2009) ASP.NET FAQs (updated July 17th 2011)
Free Stuff: WebsiteSpark|DreamSpark|BizSpark|eBooks
Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib
Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express
Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings
ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm
Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C#
My Blog - View my MCP Certifications
Yes it client side, I managed to work it out anyway, and learn something so was quite good.
The ^[1-9]{1} means:Code:^[1-9]{1}([0-9]+)?(\.[0-9][0-9]?)?
^ Start of string
[1-9] character between 1 and 9
{1} Limited to one
Finally I wrapped the [0-9] in () and added ? after which means optional as this isnt mandatory anymore
Good stuff! Yes, regex can be fun
A useful site to keep bookmarked is this one:
http://gskinner.com/RegExr/
Gary
Remember to mark your thread as resolved. Remember to rate posts that help. Hitchhiker's Guide to Getting Help at VB Forums.
ASP.NET Tutorials (updated Feb 1st 2009) ASP.NET FAQs (updated July 17th 2011)
Free Stuff: WebsiteSpark|DreamSpark|BizSpark|eBooks
Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib
Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express
Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings
ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm
Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C#
My Blog - View my MCP Certifications