Practice Exercise 2b
Objective: To become familiar with string processing.
Write a program that extracts individual words from a string instead of using the VB Split function. It must meet the restrictions specified below.
After writing the program, test it on a line like the one below. Be sure to include the multiple spaces and the double quotes. This is a VB declaration.
line = "The old dog, named ""Peewee"", ate a lot. Still, we all loved her."
You can use the Replace function to replace any hyphen with a space, but do not arbitrarily replace any other punctuation. I want you to figure out how to deal with punctuation and multiple spaces through coding rather than just replacing them by brute force.
You may need to write code to trim leading or trailing spaces (although there are other ways of dealing with them), and/or code to trim leading or trailing punctuation. The end of the line, which ends with a period rather than a space, can be particularly problematic. Don't fudge by adding a blank at the end.
The above restrictions make the coding more difficult. However, not all languages provide all of the string functions that are available in VB, and I want you to figure out how to deal with strings if those functions are not provided. You may want to write a version using the other VB functions just to compare the complexity.
If you want to read ahead and try to implement the solution using subs and functions, it seems to reduce the complexity greatly.