11-18-2011 09:35 AM
Hi all. I'm sure this question has been answered before, but I couldn't find exactly what I was looking for.
I'm having trouble with the scan from string function. My format string specifies tabs (\t) as the delimiters between multiple parameters, however it's also using spaces. As a result, a string which contains spaces causes it to fail on the next parameter because it's expecting a number but sees instead the remainder of the string.
Please see the attached.
If I replace the spaces with a token (in this case #SPACE#), I can read the string and the numbers correctly. Then, I have to re-replace the tokens with spaces after reading it back.
Therefore, what I'm looking for is a way to specify the tab charater as a delimiter, but not the space character.
thanks for your help.
Solved! Go to Solution.
11-18-2011 11:29 AM
11-18-2011 11:38 AM
That doesn't seem to work at all.
This is now my full format string: %f\t%f\t[a-zA-Z0-9 ]\t%f\n
The Format Into String is now demanding a double input where the alphanumeric characters should go.
The scan from string gives only three outputs, all numeric.
Instead of treating [a-zA-Z0-9 ] as an indicator of a string, it's treating it as a literal string and inserting it as is.
11-18-2011 11:40 AM
11-18-2011 11:42 AM
That does make a big difference.
But what if I want to include all printable characters, not just alphanumerics?
11-18-2011 11:54 AM
I would use %[^\t] in this case, which will read any character that isn't a tab.
11-18-2011 12:00 PM
Okay, that seems to work. But now I'm confused.
Why does \t match both tabs and spaces, but ^\t reads spaces but not tabs?
11-18-2011 12:03 PM
LandBelenky wrote:
Why does \t match both tabs and spaces, but ^\t reads spaces but not tabs?
It would be more accurate to say that %s doesn't match spaces. Your original code fails trying to match the tab after the %s.
11-18-2011 12:06 PM