Say, I want to change the string ‘A = (x+2.)*(y+3.)-1‘
to
‘A = (x+2.0e0)*(y+3.0e0)-1.0e0‘.
Every number like 2. or just 2 should be changed. How to do this?
Thanks a lot!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given the comment you wrote, this kind of regular expression should work:
Output:
Explanation of regexp:
(...)– means capturing group, what you need to capture to reuse during replacement\d– means any number, equivalent to [0-9]+– means 1 or more occurance, equivalent to{1,}\.?– means that we want either 0 or 1dot.?is equivalent to{0,1}In replacement:
\1– means that we want to take first captured group and insert it here