Regular Expression to Limit Lines to 76 Characters
The other day when I was at school, I typed a fairly long quasi blog post into the NHS contact form to continue to test it. When I got the e-mail at home later in the day, a line-break had been put into my post because it was such a long non-breaking string. It was broken in the middle of the word. I decided that I should automatically break the line after 76 characters. I wanted to use a regular expression. I searched Google, but could find nothing that helped. Today, I wrote one that will limit the line-length to 76 characters except when there is a long string that doesn't have any spaces in it such as a URL. I'm posting the regex here in case anyone else would find it useful.
Find:(.{1,75}\s)(?!\n)
Replace: $1\nLabels: code


0 Comments:
Post a Comment
<< Home