I have a long string with a tag appearing a couple times in it (the tag is a specific set of characters) and I need to replace that tag with another string that has a different length than the tag. I am able to use strfind to find the indeces of the tags and replace them with a "replacement" variable when the replacement is the same size as the tag, but it gives me an error when the tag is smaller or bigger. I was wondering if there is a way of adding or taking away an element from the original string to then make the assignment I was doing without the string size problems. (The tag I have is a string with 1 less character compared to the replacement.)
MATLAB: How to replace a segment of a string with another of different size
MATLABstring length errorstringstag replacement
Best Answer