Replace "-" with "E-" in output file
1 view (last 30 days)
Show older comments
Commented: Etienne on 14 Feb 2017
I have an output file that printed some numbers incorrectly, for instance, 1.7865271465-119 should be 1.7865271465E-119. I do not have control with regards to the output format. My question is how can I replace the "-" with "E-"? I have tried regexprep but it replaces the two numbers each side of the minus sign as well. Any help will be appreciated.
per isakson on 14 Feb 2017
Edited: per isakson on 14 Feb 2017
This does it
>> regexprep( '1.7865271465-119', '([\d\.]+)\-(\d+)', '$1E-$2' )
But it doesn't work with '1.7865271465+119'. This works with plus or minus
>> regexprep( '1.7865271465+119', '([\d\.]+)([\-\+])(\d+)', '$1E$2$3' )
More Answers (0)
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!