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?

 Accepted Answer

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

More Answers (0)

Asked:

on 27 Jul 2015

Commented:

on 27 Jul 2015

Community Treasure Hunt

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

Start Hunting!