Use re.sub
. Just match all the chars upto I
then replace the matched chars with I
.
re.sub(r'^.*?I', 'I', stri)
More Related Contents:
- Remove specific characters from a string in Python
- How to search and replace text in a file?
- Speed up millions of regex replacements in Python 3
- Best way to replace multiple characters in a string?
- How to use string.replace() in python 3.x
- String replace doesn’t appear to be working
- How to input a regex in string.replace?
- python replace single backslash with double backslash
- replacing text in a file with Python
- Removing a list of characters in string
- Replace nth occurrence of substring in string
- Keeping only certain characters in a string using Python?
- Python Replace \\ with \ [duplicate]
- Replace first occurrence only of a string?
- Mass string replace in python?
- Replace special characters in a string in Python
- Replacing specific words in a string (Python)
- pandas: replace string with another string
- Adding backslashes without escaping [duplicate]
- Mutable and Immutable Strings in python
- Python replace function [replace once]
- How do I concatenate items in a list to a single string?
- Fast punctuation removal with pandas
- Checking whether a string starts with XXXX
- Stripping non printable characters from a string in python
- Python __str__ versus __unicode__
- Python – How can I pad a string with spaces from the right and left?
- convert a string which is a list into a proper list python
- How to use str.contains() with multiple expressions in pandas dataframes
- How to merge two json string in Python?