in reply to how to find and split long words
Although your regex will work as intended, a URL is not a word and as such offers 'natural' places to insert a break (after a / for example). Depending on what you are actually expecting to be entered, there may be other rules that work better for other types of information. Inserting inappropriate spaces is rather akin to inserting inappropriate hyphens, you can end up with something that conveys a very different meaning than the original text. The following may do a somewhat better job:
s!(\S{10,39} (?: [a-z](?=[A-Z]) | [\\/:,.;\!?\)\]] | (?= [\(\[{]) | (? +<=\S{40}) ))!$1 !gx;
It breaks for a "CamelCase" change ("Camel Case"), after sentence and URL punctuation, before brackets, or after 40 characters if all else fails.
|
|---|