remove substring from string

17 vues (au cours des 30 derniers jours)
Omphemetse Moeng
Omphemetse Moeng le 13 Oct 2020
I want to remove a substring from an nx1 string, if I use the erase function, A = erase(Str, 'dog'). it works, however this is case sensitive and I would also like to remove all other case variations of 'dog' such as 'DOG', 'Dog', 'dOg' etc. if I use the functions upper(dog) it completely ignores the string 'Dog' and only removes 'DOG'. .
Is there a way to use the fuction while avoiding case sensitivity?

Réponses (1)

Walter Roberson
Walter Roberson le 13 Oct 2020
A = regexprep(Str, 'dog', '', 'ignorecase');
  1 commentaire
Omphemetse Moeng
Omphemetse Moeng le 13 Oct 2020
Thank you, this is fine.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by