how to remove some unwanted characters winthin a string

Hello there,
I have a text file that contains the following line:
110;115;125;to;129;155
There could be no ';' or more than one ';' between number and 'to', for example
110;115;125to;;129;155 or 110;115;125;;;to;129;155
I want to remove the ';' between the number and 'to' and get below string:
110;115;125to129;155
Is there any simple solution to this?

 采纳的回答

Try using regexprep, something like this should work:
regexprep(str,';*to;*','to')

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by