Solved! Go to Solution.
import re
def remove_codes(code_string):
# Get rid of enclosed text, ie {\instruction;Text to keep}
replaced_sequences = re.sub(r"{\\[^;]+;([^}]*)}", r"\1", code_string)
# Get rid of standalone \font|22pt; like sequences
new_string = re.sub(r"\\[^;]+;", "", replaced_sequences)
return new_string>>> remove_codes(r"\pt16.25;{\fArial|b0|i0|c0|p34;15.00m}")
'15.00m'arcpy.CalculateField_management("Annos","TEXTS","!TEXTSTRING!.remove_codes","PYTHON_9.3","")
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3128, in CalculateField raise e ExecuteError: ERROR 000539: Error running expression: "{\fArial|b0|i0|c0|p34;C - 40}".remove_codes Traceback (most recent call last): File "<expression>", line 1, in <module> AttributeError: 'str' object has no attribute 'remove_codes' Failed to execute (CalculateField).