T
T
tarp202020-06-02 18:39:55
Python
tarp20, 2020-06-02 18:39:55

How to write a regular expression in Python?

How to write a function that outputs from a large string only the part where there is 1 lowercase letter that is between 3 uppercase letters on each side
i.e.: YVYhROP and output only those lowercase characters : h

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FaustGette, 2020-06-02
@tarp20

import re

string = "YVYhROP"
res = re.search(r'[А-ЯЁA-Z]{3}([а-яёa-z])[А-ЯЁA-Z]{3}', string)
print(res.group(1))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question