When posting to Teams via API, the backslash ('`') in the string was processed by Markdown and looked strange, so trying to escape with a backslash ('') in front did not work. ..
example.rb
s = 'abc`123`xyz' # 'abc\`123\`xyz'I want to
puts s.gsub(/`/, '\`') # => abcabc123abc`123xyz
If you wonder why this is so ...,'\ `'seems to be used as a matched substring in the replacement string.
I increased the backslash and it worked
example.rb
s = 'abc`123`xyz'
puts s.gsub(/`/, '\\\`') # => abc\`123\`xyz
Even so, I want the ability to post with Markdown disabled. .. ..
Recommended Posts