I am looking to do a Regex conditional search.
What I am looking to do is if there is Carriage Return (\r) followed by Upper and Lower Case alphabets the I want to add space ('') and remove carriage return but if after carriage there is anything else I just want to replace that. Is there a way I can do that using regex in Python
Sample Input:
BCP-\rEngin\reerin\rg\rSyste\rms\rSupp\rort
Output:
BCP- Engineering Systems Support
Data is in form of dataframe. I am currently using df.replace() function to replace "\r" with spaces (" ") but I would like it to be conditional.
Below is my code -
df_replace = df.replace(to_replace=r"\r", value = " ", regex=True)