I
I
Ivan Melnikov2021-10-25 00:24:23
Python
Ivan Melnikov, 2021-10-25 00:24:23

How to modify the search for all occurrences of a string (re)?

Please tell me how to modify the search for all occurrences of a string:

import re
string = "'Everest Re Group, Ltd. [SPB: Акции]','IHS Markit Ltd. [МБ ФР: Т+ Акции и ДР]','Invesco Ltd. [SPB: Акции]'"
re.findall(r'\[.+\]', string)
output: ["[SPB: Акции]','IHS Markit Ltd. [МБ ФР: Т+ Акции и ДР]','Invesco Ltd. [SPB: Акции]"]

And I need to get: ['[SPB: Shares]',[MB FR: T+ Shares and DR]','[SPB: Shares]']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-10-25
@immelnikoff

add ?after+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question