wood burning stoves 2.0*
The moose likes Java in General and the fly likes Pattern Error while using RegEx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pattern Error while using RegEx" Watch "Pattern Error while using RegEx" New topic
Author

Pattern Error while using RegEx

pk anoop
Greenhorn

Joined: Jun 11, 2009
Posts: 7

Hi All,

I am stuck up with a problem while using Regular Expression.
My requirement is : split a long string into maximum size of 125 letters and then insert a line break in between them.
while splitting, it shouldn't split between the words. in short, i want to split a string into small strings whose length is 125 or at the end of word before 125th letter. Hope i didnt confused

i used one regexp to solve this, and believe me am an absolute zero in this.
i just got one code and copy pasted ;-)


this is my code, and it's working perfectly unless the starting string ends with a full stop(.).
In that case it is giving an error like : No match found.

Please help.

Regards,
Anoop P K
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not even sure I'd use a regex for this, honestly.
pk anoop
Greenhorn

Joined: Jun 11, 2009
Posts: 7
i want to do it with optimum performance and just am eager about this regular expression also.
Otherwise how will you do it?
regards,
anoop
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

I'd go for a simple loop. For instance:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Pattern Error while using RegEx