in reply to Re^2: Split string using regex on \n or max line length (updated)
in thread Split string using regex on \n or max line length

Hi flowdy,

You're right that my second regex didn't operate like the OP's, but if you write /(.{1,$len}\W?)/gm, then that may split in the middle of a word, like your suggestion and unlike the OP's regex. I've updated my node.

Thanks,
-- Hauke D

Replies are listed 'Best First'.
Re^4: Split string using regex on \n or max line length
by flowdy (Scribe) on Feb 14, 2017 at 10:15 UTC

    Hi haukex,

    Yes, you are right. Then again, required \W will not match at the end of the line. So, (?:\W|$) is closer to an ideal solution, which however is rather hypothetical until a proper set of positive and negative test cases is provided.