0
add = '$4.545,45 is less than $5,454.54.'

This command :

re.sub(r'(?<=\d).(?=\d{1,})',',',add)

results in

'$4,5,5,45 is less than $5,4,4,54.'

but

re.sub(r'(?<=\d).(?=\d{2,})',',',add)

results in

'$4,545,45 is less than $5,454,54.'

Second one is correct, Both means convert the one that has digitbefore then full stop then digit , then why {1,} gives weird result.

I checked https://docs.python.org/3/library/re.html as well but still confused.

Also, is there any other way to solve this as well.

halfer
  • 19,824
  • 17
  • 99
  • 186
user3222101
  • 1,270
  • 2
  • 24
  • 43

0 Answers0