in reply to Need help with regex to replace 4th \s with \n in data line
It might be better not to count the spaces, but the characters, which will be a better guess for the actual line length. You can wrap any string to a specified minimum and maximum chars per line (here:{3,30}) with that regex:
$_ = 'School of Wisdom and Knowledge College Preparatory'; s/(.{3,30})\s+(.+?)/$1\n$2/g; print;
~Django
"Why don't we ever challenge the spherical earth theory?"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Need help with regex to replace 4th \s with \n in data line
by Popcorn Dave (Abbot) on Sep 06, 2002 at 05:11 UTC |