python re how to add space from second digit and add comma before space

Viewed 18

I just start learning python regx. here is text:

2 bd1 ba2,100 sqft

how I can add space from digit and comma before space. my expected result will be look like this:

2 bd, 1 ba, 2,100 sqft

I tried this code but didn't work re.sub(r'bdbda',',',text)

I did this using python replace function .replace('bd','bd, ').replace('ba','ba, ').strip()

0 Answers
Related