Regex to match for zeros
I am looking for a regex pattern that would match several different combinations of zeros such as 00-00-0000 or 0 or 0.0 or 00000
Well, I have web service that returns me a result set, based on what it returns me I can decide if the result is worth displaying on the page. So if I get either 00-00-0000 or 0 or 00000 I would assume that data was not found, however if it brings back 001 or 000123 or 0356.00 - 1000 or 0.6700, this would be valid.
Hope this clarifies my question
I believe this is what you are searching for...
You need to better define what is valid to appear between the zeros. Going from your question, I'll assume you're looking for any number of zeros with any number and grouping of "-" and "." between them....
Hope you don't mind, SoapBox:
Based on the question edit, what you are looking for is any string that has non-zero digits in it, so:
or, if the regex engine automatically anchors start and end of string:
may be the better solution.
This is the reverse of the test you asked for but that's a simple matter to change (reverse the sense of the if-statement).
Here's the Regex that will match what you have asked for so far. If there is more you want it to match, please specify.
That matches all of the examples you asked for.
You seem to be over-complicating what needs to be done. Rather than looking for different combinations that turn out to be all zeros, why not use a regex that identifies data that you do care about.
Therefore, I suggest you use this: [1-9]
This will match if the string contains any digit that is non-zero, assuming that you're looking at numeric data, of course.