I am having a Text Like
var data = "âô¢¬ôè÷¢ : ªîø¢è¤ô¢ - ã¿ñ¬ô ñèù¢ ªð¼ñ£÷¢ ï¤ôñ¢,«ñø¢è¤ô¢ - ªð¼ñ£÷¢ ñèù¢ ÝÁºèñ¢ ï¤ô袰ñ¢ ñ¤ì¢ì£ Üò¢òñ¢ ªð¼ñ£ñ¢ð좮 è¤ó£ñ âô¢¬ô袰ñ¢,õìè¢è¤ô¢ - ÝÁºèñ¢ ï¤ôñ¢,è¤öè¢è¤ô¢ - ô좲ñ¤ ï¤ôñ¢ ñø¢Áñ¢ 1,22 ªê ï¤ôñ¢ ð£î¢î¤òñ¢";
and I am Having the Extension Method to split string
public static IEnumerable<string> EnumByLength(this string s, int length)
{
for (int i = 0; i < s.Length; i += length)
{
if (i + length <= s.Length)
{
yield return s.Substring(i, length);
}
else
{
yield return s.Substring(i);
}
}
}
public static string[] SplitByLength(this string s, int maxLen)
{
var v = EnumByLength(s, maxLen);
if (v == null)
return new string[] { s };
else
return s.EnumByLength(maxLen).ToArray();
}
Now my question is
To split this string by Maximum Length 150
and the splitting must be done only by the Nearest Spaces in it..(either before 150
or after 150
.. not in the middle of a word.
How?
.Split(' ')
a string based on spaces?, (it would help to clarify where a space is in a word) – Salpingotomy150
.. Was I asked correct??? – Blinderswhile and for loop
, whyLINQ
? – Licketysplit