split the text

  • Автор темы Автор темы feyt333
  • Дата начала Дата начала

feyt333

Новичок
Регистрация
14.08.2012
Сообщения
6
Реакции
0
Баллы
1
I have a text and I want to split 5 paragraphs.
 
please use list and Regular expressions
 
Can you give me an example ?
 
I added my sample article
 

Вложения

Im not sure what you mean. Do you wanna take first 5 sentences?
 
Im not sure what you mean. Do you wanna take first 5 sentences?
no. My article only one paragraph I want to split 5 paragraph

now
1 paragraph........................
..........................................
..........................................
..........................................
..........................................

I want

1 paragraph........................
.........................................
2 paragraph........................
.........................................
3 paragraph........................
.........................................
 
no. My article only one paragraph I want to split 5 paragraph

now
1 paragraph........................
..........................................
..........................................
..........................................
..........................................

I want

1 paragraph........................
.........................................
2 paragraph........................
.........................................
3 paragraph........................
.........................................
It seems u need use C# CODE
 
You can split the text if you have splitter in it.
upload_2014-6-9_12-35-28.png

If you want to split randomly on 5 papragraphs. You should write a snippet.
Please let us know. How exactly you want to split you text.
 
C#:
Развернуть Свернуть Копировать
string textbox = Projects.Variables["textbox"].Value;
List<string> listOfparagraphs = new List<string>();

            Regex regex = new Regex("\\[\\d+]");
            var paragraphs = regex.Matches(textbox); // get all pararaphs num as [1],[2],[3].. etc

         foreach (var paragraph in paragraphs)
            {
                string[] stringSeparators = new string[] { paragraph.ToString()};
                var text = textbox.Text.Split(stringSeparators, StringSplitOptions.None);
                listOfparagraphs.Add(text[0]); // in this list i add all paragraphs splitted by [1],[2], and others
                textbox = textbox.Replace(text[0], "").Replace(paragraph,"");
                if (textbox=="")
                    break;
            }
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)