How to put an argument of a function inside a raw string
<p>I want to create a function that will delete a character in a string of text.
I'll pass the string of text and the character as arguments of the function.
The function works fine but I don't know how to do this correctly if I want to threat it as a raw string.</p>

<p>For example:</p>

<pre><code>import re

def my_function(text, ch):    
    Regex=re.compile(r'(ch)')   # &lt;-- Wrong, obviously this will just search for the 'ch' characters
    print(Regex.sub('',r'text'))      # &lt;-- Wrong too, same problem as before. 


text= 'Hello there'
ch= 'h'

my_function(text, ch)
</code></pre>

<p>Any help would be appreciated.</p>

<pre><code>def my_function(text, ch): 
    text.replace(ch, "")
</code></pre>

<p>This will replace all occurrences of <strong>ch</strong> with an empty string.  No need to invoke the overhead of regular expressions in this.</p>

python regex string variables