import re path = r'E:\FiveMserver\server\resources\[framework]\[core]\qb-core\shared\items.lua' with open(path, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Fix pattern: find description strings that don't end with closing quote before }, # Pattern: ['description'] = 'text without closing quote}, # Should be: ['description'] = 'text with closing quote'}, fixed = 0 lines = content.split('\n') new_lines = [] for line in lines: if "['description']" in line and "['name']" in line: idx = line.index("['description']") after = line[idx:] if after.count("'") % 2 != 0: # Find the last }, and insert closing quote before it # Pattern: some text}, -> some text'}, # Or: some text}}, -> some text'}}, line = re.sub(r"([^'])\},\s*$", r"\1'},", line) line = re.sub(r"([^'])\}\},\s*$", r"\1'}},", line) # Handle CRLF line = re.sub(r"([^'])\},\r$", r"\1'},\r", line) line = re.sub(r"([^'])\}\},\r$", r"\1'}},\r", line) fixed += 1 new_lines.append(line) with open(path, 'w', encoding='utf-8') as f: f.write('\n'.join(new_lines)) print(f"Fixed {fixed} broken description strings")