By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

Regex help

P: 1
Hi all,

I'm trying to break a string at every , and .
So I have something like Pattern.compile("(\\. )|(, )");
but this is not working well for me, I wanted to change it so it will match the "." only if it found only one in a given word
Example:
"Break here. But don't break he.re."
So basically I want to know how to define a pattern that requires no more than 1 "." in a word.

Thanks alot.
Dec 21 '06 #1
Share this Question
Share on Google+
1 Reply


Colloid Snake
100+
P: 144
Hi all,

I'm trying to break a string at every , and .
So I have something like Pattern.compile("(\\. )|(, )");
but this is not working well for me, I wanted to change it so it will match the "." only if it found only one in a given word
Example:
"Break here. But don't break he.re."
So basically I want to know how to define a pattern that requires no more than 1 "." in a word.

Thanks alot.
Have you tried using the \s (indicates any whitespace) after the '.' or ','?
Dec 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.