01-09-2008 02:55 PM - edited 01-09-2008 02:56 PM
01-09-2008 04:44 PM
Derek Price wrote:
I am using this regular expression, although I'm not quite sure why it's picking up more values than it is:
Message Edited by Derek Price on 01-09-2008 03:56 PM
01-09-2008 04:50 PM
I would like to be able to validate the string and also pick out each piece. Can this be done with a single regular expression or do I need multiple calls?
Message Edited by Derek Price on 01-09-2008 03:56 PM
01-09-2008 04:56 PM
01-09-2008 05:08 PM
01-09-2008 05:12 PM - edited 01-09-2008 05:12 PM
01-10-2008 09:16 AM
01-10-2008 11:45 AM
The regular expression you construct would depend on the exact format of the string you expect.
For instance, one of your fields there is "0000.0"
What happens when a different number comes in? Would 12.34 be passed in as 12.34 or 012.34 or 12.340? How about the number 12345.6? Would be be passed in as 12345.6 or just 12345
01-10-2008 12:01 PM - edited 01-10-2008 12:03 PM
The regular expression you construct would depend on the exact format of the string you expect.
For instance, one of your fields there is "0000.0"
What happens when a different number comes in? Would 12.34 be passed in as 12.34 or 012.34 or 12.340? How about the number 12345.6? Would it be passed in as 12345.6 or just 12345 (since your field width seems to be 5 digits with a decimal point). Or is field size irrelevant as long as the fields are separated by a space character. For each of these cases, the regular expression would be different.
For each of the above cases, the rules are different and under ideal circumstances you would use a regular expression that validates it perfectly. For perfect validation, you need 2 things to simultaneously occur:
1. screening out of all possible false matches, and
2. allowing of all possible true matches.
So, the question for you is: what are the rules that govern your source string?
Regarding the last field being blank, you could use a format string of %1s %f %f %f %f %f and then use the offset past match to extract the last field. But you may not need to do this since Mercurio's method works well too. 5 stars to Mercurio for showing me a different way to do it.
Regards,