N
N
Nerlight2020-07-21 17:27:13
Python
Nerlight, 2020-07-21 17:27:13

How to extract, change and return numbers to text?

I don’t know how difficult this task is, but the essence is that you need to get numbers from the text with the ability to edit, preferably group and return the modified version to the text.

Visual:
Example text:

What is Creative Cloud?
This can be explained in 3 lines:
Creative Cloud is a collection of over 28 apps and services for photography, video, web content, design, interface development on PC and mobile devices. Built-in guides and templates help you get started. Whether you are a beginner or a professional, you will have everything to realize any ideas.

It is necessary to extract all the numbers
3, 28
Change them, for example, increase them by 2
5, 30
And return them to the text in their final form

What is Creative Cloud?
This can be explained in 5 lines:
Creative Cloud is a collection of over 30 apps and services for photography, video, web content, design, interface development on PC and mobile devices. Built-in guides and templates help you get started. Whether you are a beginner or a professional, you will have everything to realize any ideas.

How can you automate this process using Python to work with large texts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2020-07-21
@NerLight

Write a regular
expression Call it via re.sub , pass your own function as a callback, which will apply the necessary mathematical operations (increment by two, for example ).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question