This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Pattern Error while using RegEx Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 19216

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


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Pattern Error while using RegEx
 
Similar Threads
Java regex?
java.util.regex package
Large Numbers
Text search and replacement using nio
reverse the text file and write