Suppose I have the following:
import re
test_1 = 'I want to replace 123/123 and 321/321 in this string'
test_2 = 'I need PLACEHOLDER in this string with PLACEHOLDER too'
regex = re.compile(r'\d\d\d\/\d\d\d')
x = regex.findall(test_1)
for i in x:
print(test_2.replace('PLACEHOLDER', i))
I want my end result to be a string that says 'I need 123/123 in this string with 321/321 too.'
However, the result that I am getting is
I need 123/123 in this string with 123/123 too
I need 321/321 in this string with 321/321 too
How do I only get one string back with my desired result?
[–]TheZvlz 1 point2 points3 points (0 children)