Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove word from string with one condition

If match part of word in string,
how to remove that entire word?

  • Input: "This is a beautiful text in string."
  • Rule: If in string exist "autif", then delete "beautiful"
  • Result: "This is a text in string."

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If you want to check for a string, use FIND and then SUBSTITUTE.

=IF(ISERROR(FIND("autif",A1)),A1,SUBSTITUTE(A1,"beautiful",""))

There’s no need to search for it though, I can’t see why you wouldn’t just substitute it out regardless. Checking for it is a waste of time because if it exists, you will change it out, if it doesn’t exist, you won’t, so just remove it regardless …

=SUBSTITUTE(A1,"beautiful","")

If you have multiple conditions, you can throw them all into one formula …

=SUBSTITUTE(SUBSTITUTE(A1,"beautiful",""), "string", "")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading