There is a list of strings and I need to manipulate those which do not end in ",\d\d" (comma followed by two digits).
So I went to https://docs.python.org/2/howto/regex.html and tried out some code, put everything in my own function and out came something like this, however it doesn't match anything.
def translatePrice(text):
text = str(text)
text = text.strip()
if (re.search(r',\d\d$', text) == None):
print "Error in ", text
return text
I am pretty sure that my regex raw string is formatted in a way that python can understand it. What I am not sure about is if the rest of the code is any good. I also found "endswith('xy')" but that doesn't help me that much since I need to match any pair of digits.
Here is some examples of how my input strings look like:
25outputsError in 2525,25outputs25,251outputsError in 11,0outputsError in 1,01,00outputs1,00
text[-2:].isdigit() and text[-3] == ','?returnis meant to be indented (and the semicolon serves no purpose), but other than that, this should work.textis what you think it is before applying the regex?