replacing two reciprocal words in huge number of scripts

조회 수: 1 (최근 30일)
Arman
Arman 2012년 4월 1일
I have a huge number of scripts in MATLAB. I need to write a new script that will search text of script files and replace "ref" wherever it finds "mov" and also replaces "mov" wherever it finds "ref". I'm confused as apparently I can't simply write a script that replaces "mov" and "ref" and then replaces "ref" with "mov" .
Any input is much appreciated.

채택된 답변

the cyclist
the cyclist 2012년 4월 1일
Three steps:
  1. Replace ref with syzygy
  2. Replace mov with ref
  3. Replace syzygy with mov
For the script itself, you should be able to use the regexprep() command to do the replacement.
  댓글 수: 2
Image Analyst
Image Analyst 2012년 4월 1일
I'd have your script use questdlg() to show you the line of text you're planning on doing the replacement on and ask the user for confirmation. That way you can make sure you don't replace something you don't want, like if you have the word "move" or "reference" in a comment or something like that.
Arman
Arman 2012년 4월 1일
Brilliant. Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by