So I have some code that takes a text and splits it up by whatever is within
< p > and < /p >(actually has no spaces but this website wont show it like that)
its pretty simple but it only occurs for the first instance of its occurrence .. I want it to do it for all of the instances of those in the entire text .. this could be done by a loop but I have no idea how to implement the loop
```
var startTag = $"
";
var endTag = $"
";
//For comparison text
//string ImpureCText = "
Hello this is a test to see if this will give an error
hello this could possibly
you are an imbaseel
";// insert text file here
bool b = ImpureCText.Contains(startTag);
bool l = ImpureCText.Contains(endTag);
if (b && l)
{
int index1 = ImpureCText.IndexOf(startTag);
int index2 = ImpureCText.IndexOf(endTag);
if (index1 >= 0) //locates char position of start of pharagraph
Console.WriteLine("'{0} begins at character position {1}", startTag, index1 + 1);
Console.WriteLine("'{0} begins at character position {1}", endTag, index2 + 1);
// This For Pharagraph locate
//string LesserImputerText = Regex.Replace(ImpureTitleText, @"(@[A-Za-z0-9]+)|([^0-9A-Za-z \t])|(\w+:\/\/\S+)", " ").ToString(); //Gets rid of non ASCII values (from http://luisquintanilla.me/2018/01/18/real-time-sentiment-analysis-csharp/) but does seem to do anything when putting non ASCII character such as upsidedown exclamation mark.
int PCstart = ImpureCText.IndexOf(startTag) + startTag.Length; //From here to //this regex breaks it
int PCEnd = ImpureCText.IndexOf(endTag);
string PureText = ImpureCText.Substring(PCstart, PCEnd - PCstart);
Console.WriteLine(PureText);
Console.WriteLine("");
What I have tried:
foreach loops
for loops
looping the entire text - the text between the 2 points in the previous occurrence in the loop so the new text is actually just the old text without that specific string in it . inefficient and no idea how to implement some of the code