• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pattern Error while using RegEx

 
pk anoop
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not even sure I'd use a regex for this, honestly.
 
pk anoop
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go for a simple loop. For instance:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic