Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:39:44+00:00 2026-06-15T02:39:44+00:00

I have a string like: 2E6 3.34e-5 3 4.6 and I want to use

  • 0

I have a string like: "2E6 3.34e-5 3 4.6" and I want to use replaceAll to replace tokens like:

"((\\-)?[0-9]+(\\.([0-9])+)?)(E|e)((\\-)?[0-9]+(\\.([0-9])+)?)"

(i.e. two numbers with e or E between them) into the equivalent normal number format (i.e. replace "2E6" with "2000000" and "3.34e-5" with "0.0000334")

I wrote:

value.replaceAll("((\\-)?[0-9]+(\\.([0-9])+)?)(E|e)((\\-)?[0-9]+(\\.([0-9])+)?)", "($1)*10^($6)");

but I would like to actually multiply the 1st argument by 10 to the power of the 2nd argument, not just writing it that way .. Any ideas?

UPDATE

I did the following based on your suggesions:

Pattern p = Pattern.compile("((\\-)?[0-9]+(\\.([0-9])+)?)(E|e)((\\-)?[0-9]+(\\.([0-9])+)?)");
Matcher m = p.matcher("2E6 3.34e-5 3 4.6");
StringBuffer sb = new StringBuffer();
while (m.find()) {
    m.appendReplacement(sb, "WHAT HERE??"); // What HERE ??
}
m.appendTail(sb);
System.out.println(sb.toString());

UPDATE

Finally, this is what I reached:

// 32 #'s because this is the highest precision I need in my application
private static NumberFormat formatter = new DecimalFormat("#.################################");

private static String fix(String values) {
    String[] values_array = values.split(" ");
    StringBuilder result = new StringBuilder();
    for(String value:values_array){
        try{
            result.append(formatter.format(new Double(value))).append(" ");
        }catch(NumberFormatException e){ //If not a valid double, copy it as is
            result.append(value).append(" ");
        }
    }
    return result.toString().substring(0, result.toString().length()-1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:39:47+00:00Added an answer on June 15, 2026 at 2:39 am

    If you need to convert scientific number notation into normal formal you can use DecimalFormat

    public static void main(String[] args) {
        NumberFormat formatter = new DecimalFormat();
    
        double num1 = 2E6;
        formatter = new DecimalFormat("##########");
        System.out.println(formatter.format(num1)); 
    
        double num2 = 3.3e-5;
        formatter = new DecimalFormat("#.##########");
        System.out.println(formatter.format(num2));
    }
    

    Just add the logic to split the intial string over spaces and apply the above logic.

    You can check more about the symbols like #(in this case) at the javadoc for DecimalFormat.

    Symbol Location     Localized?  Meaning   
    ------------------------------------------------------------
    #      Number       Yes         Digit, zero shows as absent 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string like order by o desc,b asc Here I want to replace
I have string like First Last Name I want to replace empty spaces to
I have string like 123-123-1234 so I want to convert string into this format
I have string like [any characters]{$\prime$}[any characters]$[any characters]{$\prime$}[any characters]$[any characters] I want to replace
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have String like Dec 31, 1969 4:00:00 PM. I want to convert it
I have string like file name . I want to output like file\ name
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
i have String Like As below : alert(tempstr);//<b> Testing </b> now I want create
Hi I have string like A01 , AAA , etc. I want to extract

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.