So in my game I'm trying to get some articles from a database and split the data in separate articles. Here's my code:
IEnumerator Start () {
WWW articleData = new WWW ("http://mywebsite.com/getsomedatabase.php");
yield return articleData;
string articleDataString = articleData.text;
DevideData (articleDataString);
}
void DevideData(string data)
{
//Column 1 = article name
//Column 2 = article id
//Column 3 = option 1
//Column 4 = option 2
//Column 5 = option 3
//Column 6 = change in values that appear directly after article has come in
//Column 7 = change in values after option 1 has been chosen
//Column 8 = change in values after option 2 has been chosen
//Column 9 = change in values after option 3 has been chosen
//Column 10 = change in values after no option has been chosen
List<string> articles = new List<string> ();
string subData = data;
for (int i = 1; i < Regex.Matches (data, "|NEXT|").Count; i++) {
articles.Add(subData.Substring(0,subData.IndexOf ("|NEXT|")));
subData.Replace (subData.Substring (0, subData.IndexOf ("|NEXT|")), "");
}
}
articleDataString is basically a long string of formatted data, and each article is separated by |NEXT|. However, the method I'm using to split the string, (I don't even know if it works yet.) is too heavy for the machine to handle. That's why I'm asking if there's a more efficient, lightweighted way of separating the long string.
In C#, you can use the String array overload. Like this:
articleDataString.Split(new string[] { "|NEXT|" }, StringSplitOptions.None);