Hi All
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.
Regards
Etienne

댓글 수: 1

Adam
Adam 2017년 2월 14일
Can't you just do it in a standard text editor with a find & replace?

댓글을 달려면 로그인하십시오.

 채택된 답변

per isakson
per isakson 2017년 2월 14일
편집: per isakson 2017년 2월 14일

0 개 추천

This does it
>> regexprep( '1.7865271465-119', '([\d\.]+)\-(\d+)', '$1E-$2' )
ans =
1.7865271465E-119
But it doesn't work with '1.7865271465+119'. This works with plus or minus
>> regexprep( '1.7865271465+119', '([\d\.]+)([\-\+])(\d+)', '$1E$2$3' )
ans =
1.7865271465E+119

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2017년 2월 14일

댓글:

2017년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by