0

I am requesting an API which sometimes gives a string that contain "*" characters. I have to post the output on discord, where ** makes the text bold. I want to see if a string contains any * and if so put a markdown \ escape character in front of the *.

How can I accomplish this?

aquatic7
  • 615
  • 1
  • 6
  • 19

1 Answers1

1

As @Random Davis rightly pointed out in the comments, you can use str.replace("*","\*")and it will replace all the * occurrence.