I need to remove a string A that exists in another string B only if string A is between two spaces.
string A = "e"
string B = "the fifth letter is e "
Example for replacing ‘e’ : "the fifth letter is e " –> "the fifth letter is"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edited the answer after you edited the question. A possible regular expression to find an “e” character between two space characters is
/\se\s/. In this case I’m replacing it with an empty string"". You can usegsubwhich returns a copy of the string orgsub!to modify the original string.UPDATE: Since you edited the question again, here’s un updated answer: