Hi, I am trying to use Regular Expressions to modify text without modifying the wildcard value. Here is an example:

import re
text = 'Reference [14] and Reference [17] are References.'
text = re.sub('Reference \[\d+\]','Ref. [\d]',text)
print text

I want the output to be "Ref. [14] and Ref. [17] are References", but here is what I get: Ref. [\d] and Ref. [\d] are References. Is there a simple way to do this?

Thanks,
Smed

import re
text = 'Reference [14] and Reference [17] are References.'
print re.sub('Reference \[','Ref. [',text)

print 'Without re'
print  text.replace('Reference [','Ref. [')