MATLAB Matlab help — How to replace a word using findstr?

  • Thread starter Thread starter tdang
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
To replace a word in a sentence using MATLAB, the user seeks to change "I love flower" to "I hate flower" by utilizing findstr and array concatenation. It is recommended to ensure that replacements only affect whole words and are case-insensitive for larger documents. MATLAB's regular expressions can facilitate this process effectively. The user is directed to MATLAB's extensive documentation on string manipulation for further guidance. Functions like strrep may also be useful for this task.
tdang
Messages
1
Reaction score
0
TL;DR Summary
How to replace a word using findstr
Matlab help!
Hello
I want to create a sentence 2

sen1: I love flower
str1: love
str2: hate

How can I create sen2= "I hate flower" using findstr and array concatenation?
 
Physics news on Phys.org
In any case, for reliable use in large documents, you should do something to only replace whole words and to match regardless of capitalization. I am sure that MATLAB has some regular expressions to allow that.
 
There is an extrensive documentation from Matlab on strings here which should cover everything you need. Take a look at strrep for example.
 
  • Like
Likes FactChecker

Similar threads

Back
Top