Kuncioso
Kuncioso

Reputation: 13

python delete 2 character in string

python search character "x" next step delete this character "x" + character "x" -1 postion in string

Example x="1. 520 2. 529"

I am going to search in x "." and delete "." and number before "." in end I want it look like x=" 520 529"

Before I created this topic I only find replace one character for one character

Upvotes: 0

Views: 111

Answers (1)

mohammad
mohammad

Reputation: 2198

import re

re.sub(r'(.\.)', '', a)

Where a is the string you want to replace in.

Upvotes: 3

Related Questions