Jun-28-2023, 11:13 AM
SOLUTION 1:
FIND:
SOLUTION 2:
FIND:
SOLUTION 3:
SOLUTION 5: (use re.MULTILINE )
FIND:
b_content = re.search('^\s*<a href="(.*?)" title="View', new_file_content).group(1)REPLACE:
old_file_content = re.sub(', in <a href="(.*?)" title="Vezi', f', in <a href="{b_content}" title="Vezi', old_file_content)
SOLUTION 2:
FIND:
b_content = re.match(r'^\s*<a href="(.*?)" title="View', new_file_content).group(1)REPLACE:
old_file_content = re.sub(', in <a href="(.*?)" title="Vezi', f', in <a href="{b_content}" title="Vezi', old_file_content)
SOLUTION 3:
import re b_content = re.match(r'^\s*<a href="(.*?)" title="View', new_file_content) if b_content is not None: b_content = b_content.group(1) else: b_content = "No match found"SOLUTION 4:
import re match = re.search('^\s*<a href="(.*?)" title="View', new_file_content) if match is not None: b_content = match.group(1) old_file_content = re.sub(', in <a href="(.*?)" title="Vezi', f', in <a href="{b_content}" title="Vezi', old_file_content) else: print("No match found")
SOLUTION 5: (use re.MULTILINE )
import re match = re.search('^\s*<a href="(.*?)" title="View', new_file_content, re.MULTILINE) if match is not None: b_content = match.group(1) old_file_content = re.sub(', in <a href="([^"]*)" title="Vezi', f', in <a href="{b_content}" title="Vezi', old_file_content) else: print("No match found")