We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › modifying data from loadStrings
Page Index Toggle Pages: 1
modifying data from loadStrings (Read 841 times)
modifying data from loadStrings
May 19th, 2005, 10:18pm
 
I’ve been writing a program that I intend to be able to modify data imported from loadStrings, specifically I’d like the program to remove all tabs and returns so that only spaces between words remain. Is this possible? If so, how?
Re: modifying data from loadStrings
Reply #1 - May 20th, 2005, 4:04am
 
something like this oughta work:

// get the lines
String lines[] = loadStrings("things.txt");
// make into a single line
String single = join(lines, " ");
// break into words on one or more whitespace chars
String words[] = split(single);

if you wanted to get rid of, say, commas and periods as well:
String words[] = split(single, WHITESPACE + ".,");

good luck!
Page Index Toggle Pages: 1