deleting the first word in a string

hi! i'm learning regex and with this code i would like to

1) print a string (from "Hi my name is SandraPandra. do not print this")

2) remove the first word and print the new, shorter string

3) remove the first word in the new, shorter string and print the newer and shorter string

4) continue this until it hits a non-character (e.g period, colon, quotation marks etc)

does anyone here know how i should change my code in order to achieve this?

here's my code:

class Testar{

publicstaticvoid main(String[] args){

String partDesc ="Hi my name is SandraPandra. do not print this.";

do{

System.out.println(partDesc);

partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");}

while (partDesc.equals("\\w") ==true);

if (partDesc.equals("\\w") ==false){//this is where something goes wrong

System.out.println("found a full stop!");}

}

}

the outcome now is:

Hi my name is SandraPandra. do not print this.

found a full stop!

Thank you in advance!

[1769 byte] By [SandraPandraa] at [2007-11-27 5:05:50]
# 1
> while (partDesc.equals("\\w") == true)This will always be false because your String doesn't equal to the String "\w" ... You can't use a regex within equals().
quittea at 2007-7-12 10:24:24 > top of Java-index,Java Essentials,Java Programming...
# 2

I answered this question in your [url=http://forum.java.sun.com/thread.jspa?threadID=5173829]previous thread[/url]. (Sorry, I didn't realize "I'm going to bed now" was a code for "I won't be reading this thread any more". ^_^ )

I would also like to point out that it's bad form to write conditions like if ( booleanExpression == true )

It's gratuitously verbose, and it creates the potential for subtle bugs. Suppose the boolean expression is a non-final boolean variable, and you accidentally leave out one of the equals signs: if ( booleanVariable = true )

An assignment statement evaluates to the value that was assigned, so this "condition" will always be true.

uncle_alicea at 2007-7-12 10:24:24 > top of Java-index,Java Essentials,Java Programming...
# 3
just being a bit too quick. anyway thanks for helping, got it to work!
SandraPandraa at 2007-7-12 10:24:24 > top of Java-index,Java Essentials,Java Programming...