O
O
onlinejunior2020-05-24 06:16:41
go
onlinejunior, 2020-05-24 06:16:41

How to turn regexp into 1 line?

I have a string:

КАТЕГОРИЯ: ТекстИСТЕЦ: Текст.ОТВЕТЧИК: Текст

I extract "Text" from it:

re := regexp.MustCompile(`(КАТЕГОРИЯ:\s+)(.*)(ИСТЕЦ)`)
re := regexp.MustCompile(`(ИСТЕЦ:\s+)(.*)(ОТВЕТЧИК)`)
re := regexp.MustCompile(`(ОТВЕТЧИК:\s+)(.*)`)


how to make regular expressions like this from the data:

re := regexp.MustCompile(`(?P<Year>\d{4})-(?P<Month>\d{2})-(?P<Day>\d{2})`)
re := r.FindStringSubmatch(`2015-05-27`)


Without calling 3 times:

re := regexp.MustCompile(``)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-05-24
@onlinejunior

КАТЕГОРИЯ:\s+(?P<Category>.*)ИСТЕЦ:\s+(?P<Plaintiff>.*)ОТВЕТЧИК:\s+(?P<Defendant>.*)

https://regex101.com/r/YOLDZl/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question