| 1. |
Solve : Documentation for String Length? |
|
Answer» I was on SO and came across this post that asked how to break a string by delimiter and then count how many strings exist. The given answer(at the time) was this: I'm just wondering how the person who posted the answer was able to figure it out.It's just putting basic batch stuff together. They knew these things: 1. This is an example of batch string replacement: %string:.= % It means "the variable %string%, with each period (dot) changed to a space" 2. The replacement makes 17.09.01.04.03 become 17 09 01 04 03 3. A simple FOR command repeats once for each space-separated token 4. The variable %count% is set to 0 (zero) at the beginning. 5. Each time FOR repeats, the set /a count+=1 adds 1 (one) to the value of %count% 6. At the end, %count% is equal to the number of tokens. |
|