This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
So my interest is to this the same program using Pattern, so I tried and wrote this:
My problem is that the second program, is writing with space before the words, and I don't wanna this, because in the program using scanner don't do, and I want to learn how to do the same thing using Pattern.....
Do you know what \\D stands for? Why would it lead to spaces being included?
Hope this helps you getting into the right direction - teaching a man to fish, and all that...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Frederico Benevides
Greenhorn
Joined: Jan 15, 2006
Posts: 25
posted
0
I know what is \D , is to get everything that is not a number...
I know will get the space too... but I don't know how to get only the words... if I choose \w+ will get the numbers too, that's my problem.
So you want to match anything that's not a digit or a whitespace character? Take a look at negated character classes. Also, there's a good regex tutorial here:
Or one of the other predefined character classes, as described in the JavaDoc for the Pattern class - for example \p{Alpha}. Of course this depends on what *exactly* you want to match...
Frederico Benevides
Greenhorn
Joined: Jan 15, 2006
Posts: 25
posted
0
I used \p{Alpha} worked here, and I used too [a-z]+ worked too.