I have a txt file which contains a lot of strings such as 

```
Chr(101)
Chr(97)
Chr(104)
...

```

I am using the below code to find all occurrences of such strings using regex. What I'd like to do is to replace each occurrence with its evaluated output. So in this case I'd replace the above with:

```
e
a
h

```

The code I have is as follows:

```
with open(oFile, "r") as f:
    for line in f:
      # find all occurrences of Chr(\d+\) and put in a list
      chrList = [str(s) for s in re.findall(r'Chr\(\d+\)', line)]
      # print chrList 
      for c in chrList:
        # print eval(c.lower())
        out = re.sub(c, eval(c.lower()), line)

```

If I print the `eval(c.lower())` line then it outputs as expected. However the `re.sub` line fails with the following error:

> 
> 
> ```
> raise error, v # invalid expression sre_constants.error: bogus escape (end of line)
> 
> ```
> 
> 

Not sure where I'm going wrong here.