remove substring from string

조회 수: 22 (최근 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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by