как разбить текст на абзацы рандомно???

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6
Здравствуйте. Нашол на форуме такую регулярку которая делит текст на абзацы по три предложения - (.*?\.){3} , мне нужно поделить абзацы на разное количество предложений. Если я пишу так (.*?\.){2,5} то оно делит текст по 5 предложений т.е. берет большое значение, а не предел от первого до второго. Помогите пожалуйста как её подкорректировать что бы работала нормально?
 

ibred

Client
Регистрация
04.04.2015
Сообщения
3 835
Благодарностей
3 545
Баллы
113
Код:
(.*?\.){{-Random.Int-|-2-|-5-}}
 

doc

Client
Регистрация
30.03.2012
Сообщения
8 613
Благодарностей
4 601
Баллы
113
регулярки рандомно не работают. Тут алгоритм нужен и цикл
 

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6

ibred

Client
Регистрация
04.04.2015
Сообщения
3 835
Благодарностей
3 545
Баллы
113
она почему-то берет сначала 2 предложения, а потом до конца все по 5. Проверял несколько раз с разными значениями.
У меня отрабатывает корректно. Покажите текст.
 

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6
регулярки рандомно не работают. Тут алгоритм нужен и цикл
а есть другой способ разбить текст на абзацы с разным количеством предложений?, может как-то C# можно?)
 

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6

ibred

Client
Регистрация
04.04.2015
Сообщения
3 835
Благодарностей
3 545
Баллы
113
а есть другой способ разбить текст на абзацы с разным количеством предложений?, может как-то C# можно?)
Код:
string text = project.Variables["НАЗВАНИЕ ПЕРЕМЕННОЙ"].Value;
Random r = new Random();
int randomNumber = r.Next(2, 5);
return Regex.Match(text, @"(.*?\.){"+randomNumber+"}").Value;
Ну, я вообще-то текст просил, а не скриншот :-)
 
  • Спасибо
Реакции: booms1

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6
Код:
string text = project.Variables["НАЗВАНИЕ ПЕРЕМЕННОЙ"].Value;
Random r = new Random();
int randomNumber = r.Next(2, 5);
return Regex.Match(text, @"(.*?\.){"+randomNumber+"}").Value;
Ну, я вообще-то текст просил, а не скриншот :-)
Adderall is used primarily as a treatment for attention deficit hyperactivity (ADHD) disorder and narcolepsy. As in-demand as this drug is for the large number of parents with children who are diagnosed with ADHD, it is best to go to an Adderall online pharmacy to find the drug if you want to be sure to find it in stock.What It ContainsAdderall is classified as both an amphetamine and a dextroamphetamine. These are stimulants that affect the chemicals in the brain. They also affect motor control and impulses, and when administered to hyperactive patients, they can allow that person to exercise more control over their nerves and impulses. This permits patients to focus more easily, to have a clearer mind and to have the ability to live like everyone else despite a serious medical condition. Dosage and UsageIt is important for consumers to know that it can be extremely dangerous to take Adderall while also taking an MAO inhibitor. Even taking an MAO inhibitor in the last two weeks can still cause an adverse reaction with Adderall.This drug should only be taken under advice from a medical doctor. Typically, the doctor will prescribe Adderall 30mg tablets. But recommended dosage may vary from patient to patient. After you have been taking the drug for a while, your doctor may recommend a different dosage as your body adjusts to it and as your doctor can tell how it affects you. Adderall should always be swallowed whole and never broken or chewed. Because of the effects it can have on the heart, it should never be shared or taken without medical advice. Side EffectsThe most common side effects you may experience while taking Adderall include a loss of appetite (leading to weight loss), dry mouth, insomnia, stomach pain, headache and a faster heart rate. More severe side effects include heart palpitations, seizures, muscle twitches, vision changes, unexplained tenderness or pain, paranoia and chest pain. If you start to experience any of these, then you need to stop taking the drug right away and contact your doctor.You should also be aware of the symptoms of an allergic reaction. Some people are allergic to Adderall, and their symptoms may include flu or fever like symptoms (runny nose, coughing, wheezing), difficulty breathing and rashes. If you experience any of these, stop taking the drug immediately and seek medical attention. An allergic reaction to any drug can be life threatening. Purchasing InformationIf you buy Adderall online, you are likely spend far less on your medication than you would otherwise. The prices are simply cheaper online than they would be at your local pharmacy. That’s because there are fewer people involved in the selling process, so less money needs to be spread around. Adderall is essential for many people to be able to live their lives normally, so if you have to have it, but you can’t afford it from your pharmacy, then it’s a good idea to order Adderall online.
 

doc

Client
Регистрация
30.03.2012
Сообщения
8 613
Благодарностей
4 601
Баллы
113

ibred

Client
Регистрация
04.04.2015
Сообщения
3 835
Благодарностей
3 545
Баллы
113
Adderall is used primarily as a treatment for attention deficit hyperactivity (ADHD) disorder and narcolepsy. As in-demand as this drug is for the large number of parents with children who are diagnosed with ADHD, it is best to go to a...
У меня работает корректно, как макрос, так и решение на C#.
Я код Вам написал, работает?
 

doc

Client
Регистрация
30.03.2012
Сообщения
8 613
Благодарностей
4 601
Баллы
113

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6
У меня работает корректно, как макрос, так и решение на C#.
Я код Вам написал, работает?
код работает в один раз т.е. один абзац делает, можно увидеть скрин макроса?, может я что-то не то делаю.
 

hameleonds

Client
Регистрация
04.10.2015
Сообщения
63
Благодарностей
0
Баллы
6

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