I'm new to JavaScript and regular expression. I'm trying to automatically format a text document to specific number of characters per line or put a "\r" before the word.
This is functionally similar to Wordwrap found in numerous text editors.
Eg. I want 10 characters per line
Original:My name is Davey Blue.
Modified:My name \ris Davey \rBlue.
See, if the 10th character is a word, it puts that entire word down into a new line.
I'm thinking the following should work to some degree /.{1,10}/ (This should find any 10 characters right?)
Not sure how to go about the rest.
Please help.