Talk:StringUtil

The word wrap function is a bit verbose. Usually code scanning strings character by character is a sign that one could find system library functionality to do it with less code. Here's an example that uses a regular expression to do the hard work for you. (Untested btw.)

import System.Text.RegularExpressions;

static function Wrap(str : String, lineLength : int) : String { if (str.Length <= lineLength) return str; var regex = String.Format("(.{1}1,{2}{3})(\\s+|$)\\n?|(.{1}{2}{3})", "{", lineLength, "}"); return Regex.Replace(str, regex, "$1$3\n"); } --KeliHlodversson 06:22, 29 March 2007 (PDT)