V
V
VoKaPTV2021-06-18 22:59:07
Python
VoKaPTV, 2021-06-18 22:59:07

How to exclude a word from a command in VK bot?

The community is sending a message, the bot must accept this message by accepting and removing the number, example:

Example:

1) 10 - the bot must accept and remove the ' 1) ' + pass it through the condition and continue the code

If anyone has any suggestions, I will be very glad to read.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-06-18
@VoKaPTV

import re

inp_str = "1) 25"


def chelik_s_habra_poprosil(input_data: str) -> str:
    find_pattern = re.match(r'\d+\)', inp_str) # "1)"
    ...
    Тут свои проверки
    ...
    return re.sub(r'\d+\)\s*', '', inp_str) 

new_str = chelik_s_habra_poprosil(inp_str) # "25"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question