...

View Full Version : split sentance in to array



homerUK
03-18-2004, 09:11 AM
Hey,

I have a string which is like the following



Dear {firstname},

Recently you.....


I read it in to an array and split up the paragraph based on " " (a space). The problem is, the above example has no space... so the array looks like



array[0] = "Dear";
array[1] = "{firstname},Recently";
array[2] = "you";


is there a way I could split the string based on commas, full stops or any other way? what's best?

javaPete
03-18-2004, 03:27 PM
i don't have the exact code to use but i would first subsitute linebreaks for spaces then split into an array. Character escapes that represent new lines are '\r' '\n'. but i'm not sure they are applicable in this situation.

liorean
03-18-2004, 09:03 PM
try something like this:
test.split(/\s/g)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum