remove substring from string

23 ビュー (過去 30 日間)
Omphemetse Moeng
Omphemetse Moeng 2020 年 10 月 13 日
コメント済み: Omphemetse Moeng 2020 年 10 月 13 日
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?

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 10 月 13 日
A = regexprep(Str, 'dog', '', 'ignorecase');
  1 件のコメント
Omphemetse Moeng
Omphemetse Moeng 2020 年 10 月 13 日
Thank you, this is fine.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by