Hey, I have this character array F='(B~C) + (~AB)'. How can I assess the array to locate all the terms that has a ~ before it and replace it with a ('). So ~C should be C'. Therefore I would like F to be F=(BC') + (A'B)

 채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 6일

0 개 추천

F='(B~C) + (~AB)'
F = regexprep(F, '~(.)', '$1''')

추가 답변 (1개)

BobH
BobH 2020년 3월 6일
편집: BobH 2020년 3월 6일

0 개 추천

See regexprep and remember that to get a single-quote it must be doubled up in the replacement string
F='(B~C) + (~AB)';
regexprep(F,'~(.)','$1''') % ~ plus next character into that character plus single quote
ans =
(BC') + (A'B)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

2020년 3월 6일

편집:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by