- Home /
Question by
Djaydino · Sep 05, 2017 at 04:45 AM ·
liststring.split
Split rich text into a list including the richtext code
Hi, I'am trying to find a way to split this properly but until now i bump into many issues.
using string.split / string.substring, string.indexof, string.replace and so on.
here is a sample string that needs to be split into a list.
We are <b><i>very</i></b><b>a</b>mused!\nThank you.
and the result in the list should be in this order :
We
are
<b>
<i>
very
</i>
</b>
<b>
a
</b>
mused!
\n
Thank
you.
So what i am trying to do is this :
splitStart = baseString.Value.Split(' ');
foreach (string part in splitStart)
{
if (part.Contains("<"))
{
// get the parts <b> <i> <size> <color> </b> </i> </size> </color> \n
textlist.Add(part); // add each part to list
}
else
{
textlist.Add(part);
Debug.Log(part);
}
}
}
tried things like contains("") replace "" "" and add "" to array but that can break the sequence.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612134217im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Saving or get array of string - PlayerPrefs 0 Answers
A respawn script for enemies. 1 Answer
How to animate a list of GameObject from their localposition 1 Answer
Creating a multidimensional array List 2 Answers