| Author |
How to add multiple delimeters to a regular expression?
|
vahid mirjamal
Greenhorn
Joined: Feb 24, 2009
Posts: 9
|
|
String tokens[] = essayInput.split("\\.");
How can i get that to also recognize the following:
a space, ! ? and .
I've been trying for hours, and only got the period to work.
Any ideas?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26168
|
|
Vahid,
If you put the character between braces, the special meaning doesn't apply. For example:
[ .?!]+
This matches one or more of a few special characters
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
vahid mirjamal
Greenhorn
Joined: Feb 24, 2009
Posts: 9
|
|
Thanks!
What's the plus for?
Also how do you get it to exclude extra spaces in between two words like if someone says : I like cake. it would count 3 spaces instead of 1. Any ideas?
Thanks
|
 |
Vikas Kapoor
Ranch Hand
Joined: Aug 16, 2007
Posts: 1374
|
|
vahid mirjamal wrote:Thanks!
What's the plus for?
You might need to look at Regex
It's bit tedious.
And I read your first post but I couldn't understand your problem. Can you be little more clear?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32638
|
|
|
I think the plus means "one or more occurrences of . . . "
|
 |
 |
|
|
subject: How to add multiple delimeters to a regular expression?
|
|
|