python - Remove period[.] and comma[,] from string if these does not occur between numbers -
i want remove comma , period text when these not occur between numbers.
so, following text should return
"this shirt, nice. costs dkk ,.1.500,00,." "this shirt nice costs dkk 1.500,00"
i tried
text = re.sub("(?<=[a-z])([[$],.]+)", " ", text)
but not substitute in text.
you try this:
>>> s = "this shirt, nice. costs dkk ,.1.500,00,." >>> re.sub('(?<=\d)[.,]|[.,](?=\d)', '', s) 'this shirt nice costs dkk 1.500,00'
using positive lookbehind assertion check symbols preceded non digit character, , alternation on same character set using positive lookahead assertion check followed non digit character.
Comments
Post a Comment