T
T
TechNOIR2017-10-11 12:04:52
Regular Expressions
TechNOIR, 2017-10-11 12:04:52

Regular expressions: How to make a line break?

Good afternoon.
I get text like:

Назначение: Моторные Применяемость: Масло для тягачей минеральное Тип масла: минеральное

Is it possible to make a regular expression (namely regular) like this in a column?:
Назначение: Моторные
Применяемость: Масло для тягачей минеральное
Тип масла: минеральное

thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2017-10-11
@TechNOIR

If capital letters are only at the beginning of the category name and its value, then here is a python:

import re

s = "Назначение: Моторные Применяемость: Масло для тягачей минеральное Тип масла: минеральное"
print(re.sub(r'([^:])\s+([А-ЯЁ])', r'\1\n\2', s))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question