I am having the string data in database table like this 1. Spray directly onto the surface to be cleaned. 2. Leave for one minute. 3. Wipe with a damp cloth. 4. At kraftgit ingrained dirt, work the surface with a cloth and rinse with water. Do not let the product dry on the surface being treated. 5. To clean plastic or painted surfaces diluted product: 30 ml to 4 liters of water. 6. When used on carpets or fabric, first test on a hidden surface.
i want to display in view like this :
1. Spray directly onto the surface to be cleaned.
2. Leave for one minute.
3. Wipe with a damp cloth.
4. At kraftgit ingrained dirt, work the surface with a cloth and rinse with water. Do not let the product dry on the surface being treated.
5. To clean plastic or painted surfaces diluted product: 30 ml to 4 liters of water.
6. When used on carpets or fabric, first test on a hidden surface.
is there any possibility to achieve my way help me if any one knows.
@helper FormatStringAsNumberList(string source)
{
for (int i = 1; i <= 6; i++)
{
var separator = i + ".";
source = source.Replace(separator, "<br/>" + separator);
}
@Html.Raw(source)
}
And calling it like:
@FormatStringAsNumberList(stringData)
Where stringData is your string from the database. You can offcource change the number 6 in the for loop if you know there is going to be more than one list item.
Off cource this is not bulletproof since there is always the possibility that a user (i just assume the string data is editable) uses a number followed by a . in an actual line, but its A way.
var input = "1. Spray directly onto the surface to be cleaned. 2. Leave for one minute. 3. Wipe with a damp cloth. 4. At kraftgit ingrained dirt, work the surface with a cloth and rinse with water. Do not let the product dry on the surface being treated. 5. To clean plastic or painted surfaces diluted product: 30 ml to 4 liters of water. 6. When used on carpets or fabric, first test on a hidden surface. 7. ";
var pattern = @"(\d\.)"; // encapsulate pattern in parenthesis and the "splitted by" part will also be returned
var values = Regex.Split(input, pattern).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
var result = new List<string>();
for (var i = 0; i < values.Length; i++)
{
if (i + 1 >= values.Length)
continue;
if (i % 2 == 0)
result.Add(values[i] + values[i + 1]);
}
var readable = string.Join("<br>", result).ToArray();
splitting the text string by Numbers wise
Hi ,
I am having the string data in database table like this 1. Spray directly onto the surface to be cleaned. 2. Leave for one minute. 3. Wipe with a damp cloth. 4. At kraftgit ingrained dirt, work the surface with a cloth and rinse with water. Do not let the product dry on the surface being treated. 5. To clean plastic or painted surfaces diluted product: 30 ml to 4 liters of water. 6. When used on carpets or fabric, first test on a hidden surface.
i want to display in view like this :
1. Spray directly onto the surface to be cleaned.
2. Leave for one minute.
3. Wipe with a damp cloth.
4. At kraftgit ingrained dirt, work the surface with a cloth and rinse with water. Do not let the product dry on the surface being treated.
5. To clean plastic or painted surfaces diluted product: 30 ml to 4 liters of water.
6. When used on carpets or fabric, first test on a hidden surface.
is there any possibility to achieve my way help me if any one knows.
Hello Raja.
Maybe you could do a helper in your view like:
And calling it like:
Where stringData is your string from the database. You can offcource change the number 6 in the for loop if you know there is going to be more than one list item.
Off cource this is not bulletproof since there is always the possibility that a user (i just assume the string data is editable) uses a number followed by a . in an actual line, but its A way.
Best of luck to you!!
Another way to go could be:
is working on a reply...