0
title= re.findall(r"[#]([^\s#@$\\|]*)(?=[\s#@$\\|])", content)

I have this regex function with which I want to get all the values in a string if they start with a hash sign. But I couldn't get it to work if a substring is at the end of the string and nothing fallows it. I've tried to remove the first "$" but it didn't work. It works when I append one space to the string but as I'm going to modify the function to ignore spaces I don't want to do it anymore.

For example if the string is:

a="#title1 #title2 #title3"

The result is:

{"title1","title2"}

But I want it to be:

{"title1","title2","title3"}
bourplan
  • 9
  • 4

0 Answers0