Search code examples
pythonpython-re

Python: Remove all types of bullet points from a string


As the question states.. My requirement is to remove all types of bullet points ("•","●"....).

Strange thing is that I am opening a file from Python Code using open(FilePath,encoding="utf8") and storing all the data in a variable and the bullet points are coming out as a string instead of /u____.

Now I want to replace all those Bullet points via Regex or any logic.

Can please someone provide me something??


Solution

  • I found the solution.

    It never came to my mind that it's not about removing/replacing the bullet points. But, it was all about considering text other than that. It sounds same but programmatically different.

    Solution: I used re.

    My_All_File_Text_With_Bullets = re.sub('[^a-zA-Z0-9 \n\.]', ' ', My_All_File_Text_With_Bullets)
    

    And this works like a charm.