Regex.Split?

Hey, i want to split a string whenever there is a “\n”, but as there is no Regex in MF4.2, does anybody know how i could do that?

Thank You

void output(string text)
        {
                if (text.IndexOf("\n") > 0)
                {
                    string[] lines = Regex.Split(text, "\n"); // any workaround for that?

                    foreach (string line in lines)
                    {
                        zeilen.Add(line);
                    }
                }
                else
                {
                    zeilen.Add(text);
                }

                while (zeilen.Count > 15)
                {
                    zeilen.RemoveAt(0);
                }

                int textpos = 1;

                Bitmap buff = new Bitmap((int)display.Width, (int)display.Height);

                for (int i = 0; i < zeilen.Count; i++)
                {
                    buff.DrawText((string)zeilen[i], MyFont, Colors.Green, 5, textpos);
                    textpos += 15;
                }

                display.SimpleGraphics.DisplayImage(buff, 0, 0);
      
        }

You have it directly in the system.string :


string source = "bla\nbla";
char[] delimiter = new char[1] { '\n'};
string[] _parts = source.Split(delimiter);

i didn’t know '\n" is just one char…

Thank You :wink:

Yes, it is ASCII(10) Line Feed, where`\r’ is ASCII(13) Carriage Return…

You’re welcome !