Подскажите регулярку пожалуйста

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

MaxLucky

Client
Регистрация
13.08.2017
Сообщения
239
Реакции
18
Баллы
18
Нужно отсечь последнее предложение в переменной. И обязательно условие, чтобы отсекаемое предложение начиналось через точку и сразу текст. Без пробела.

Пример:

"What is meant by ovarian follicle?

time or another, eggs in ovarian follicles (i.e., developing eggs); it undergoes fluctuations in size and appearance that correlate with stages of the reproductive cycle. The cortex also contains remnants of ovulated follicles and, in mammals, clusters of interstitial cells that, in some species, are glandular.ovarian follicle | anatomy - Encyclopedia Britannica"

Нужно отсечь: "ovarian follicle | anatomy - Encyclopedia Britannica". И тексты разные будут в работе, поэтому условие должно обязательно учитываться.
 
What is meant by ovarian follicle?

time or another, eggs in ovarian follicles (i.e., developing eggs); it undergoes fluctuations in size and appearance that correlate with stages of the reproductive cycle. The cortex also contains remnants of ovulated follicles and, in mammals, clusters of interstitial cells that, in some species, are glandular.ovarian follicle | anatomy - Encyclopedia Britannica
Взять последнее предложение из любой статьи (предложения могут оканчиваться на "." или "!" или "?" или "!?")
C#:
Развернуть Свернуть Копировать
(?<=[\.\?\!]+\ ).*?$

п.с. возможно пригодиться)
 
  • Спасибо
Реакции: fridayman и MaxLucky
С тем примером прокатило.

Однако с текстом, где после точки с большой буквы начинается предложение, регулярка не подходит.

Пример:

"Commonly, the follicle cells are attached to the oocyte. Follicle cells play an important role in oocyte degeneration. In particular, the functions of follicle cells during oocyte degeneration are associated with phagocytosis and the intracellular digestion of products.Oocyte Degeneration Associated with Follicle Cells in Female Mactra ..."

Тут нужно отсечь "Oocyte Degeneration Associated with Follicle Cells in Female Mactra ..."
 
C#:
Развернуть Свернуть Копировать
(?<=[\.\?\!]+\ ).*?$

Пригодилось!

С тем примером прокатило.

Однако с текстом, где после точки с большой буквы начинается предложение, регулярка не подходит.

Пример:

"Commonly, the follicle cells are attached to the oocyte. Follicle cells play an important role in oocyte degeneration. In particular, the functions of follicle cells during oocyte degeneration are associated with phagocytosis and the intracellular digestion of products.Oocyte Degeneration Associated with Follicle Cells in Female Mactra ..."

Тут нужно отсечь "Oocyte Degeneration Associated with Follicle Cells in Female Mactra ..."

Я наколдовал регулярку, но не подскажу, как ее адаптировать в ZP.

Выглядит она вот так:
C#:
Развернуть Свернуть Копировать
(?<=[\.\?\!]+).*?\.*

Проверить можно на https://regex101.com/

2022-05-28_15-42-20.png
 
Пригодилось!



Я наколдовал регулярку, но не подскажу, как ее адаптировать в ZP.

Выглядит она вот так:
C#:
Развернуть Свернуть Копировать
(?<=[\.\?\!]+).*?\.*

Проверить можно на https://regex101.com/

Посмотреть вложение 92466
Круто! Подскажите кто-нибудь, как её адаптировать, пожалуйста.
 

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