MATLAB: How to remove some unwanted characters winthin a string

regexprepreplace

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?

Best Answer

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