4
GOAL
I am trying to remove all elements of the array from the contents ":PM"
with regex, but is returning me error.
DETAILS
The array will always contain ":PM", and it is only this part that I wish to remove from the array elements.
SCRIPT
import re
array = ['SOLDADO1:PM','SOLDADO2','SOLDADO3:PM','SOLDADO4','SOLDADO5:PM']
regex = r"^...-(.*)"
re.match(regex, array)
for linha in array:
print(linha)
OUTPUT
Traceback (Most recent call last): File "regex.py", line 6, in re.match(regex, array) File "C: Python27 lib re.py", line 141, in match Return _Compile(Pattern, flags). match(string) Typeerror: expected string or buffer
Oops, thank you very much, your didactic was perfect, congratulations!
– Luis Henrique