I’m getting a string similar to the following back from the database:
The object of the following is to do: * blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninteresting text. Followed by yet another sentence full of extremely uninteresting text. Thankfully this is the last sentence.
I need to format this so that each * represents a bullet point, and the sentence after the last * goes onto a new line, ideally as follows:
The object of the following is to do: * blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninteresting text. Followed by yet another sentence full of extremely uninteresting text. Thankfully this is the last sentence.
It’s easy enough to split the string by the * character and replace that with <br /> *. I’m using the following for that:
string description = GetDescription();
description = description.Replace("*", "<br />*"); // it's going onto a web page.
but the result this gives me is:
The object of the following is to do: * blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninteresting text. Followed by yet another sentence full of extremely uninteresting text. Thankfully this is the last sentence.
I’m having a bit of difficulty identifying the fist sentence after the last ‘*’ so I can put a break there too. Can somebody show me how to do this?
If it can be assumed that the
fist sentence after the last '*'is separated by a period – then you can do the following:*characters<br>and then find the first.after it.*with<br/>*Here’s some code to get you going: (it may not be perfect). I’m using
string.Split()here rather thanstring.Replace()because I find it makes the logic easier to follow. The trick is that the last subRegion consists of two parts (the bullet and the sentence after the bullet).