What is the problem of this code

Did you write the regex or just search for it?

There isn’t anything wrong with using a premade regex (IRL) but in this case, it would have been better to get your own solution working first. Not that I would suggest it over using a regex.

Anyway, hopefully, you understood what the problem was with your initial code.


Edit: I blurred the code just to avoid spoilers and formatted it.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).