<bdo id='1DPBC'></bdo><ul id='1DPBC'></ul>
<legend id='1DPBC'><style id='1DPBC'><dir id='1DPBC'><q id='1DPBC'></q></dir></style></legend>
  • <tfoot id='1DPBC'></tfoot>

    1. <small id='1DPBC'></small><noframes id='1DPBC'>

      <i id='1DPBC'><tr id='1DPBC'><dt id='1DPBC'><q id='1DPBC'><span id='1DPBC'><b id='1DPBC'><form id='1DPBC'><ins id='1DPBC'></ins><ul id='1DPBC'></ul><sub id='1DPBC'></sub></form><legend id='1DPBC'></legend><bdo id='1DPBC'><pre id='1DPBC'><center id='1DPBC'></center></pre></bdo></b><th id='1DPBC'></th></span></q></dt></tr></i><div id='1DPBC'><tfoot id='1DPBC'></tfoot><dl id='1DPBC'><fieldset id='1DPBC'></fieldset></dl></div>

      1. 从字符串中解析多个双精度数

        Parse multiple doubles from a String(从字符串中解析多个双精度数)
        <i id='fQl0l'><tr id='fQl0l'><dt id='fQl0l'><q id='fQl0l'><span id='fQl0l'><b id='fQl0l'><form id='fQl0l'><ins id='fQl0l'></ins><ul id='fQl0l'></ul><sub id='fQl0l'></sub></form><legend id='fQl0l'></legend><bdo id='fQl0l'><pre id='fQl0l'><center id='fQl0l'></center></pre></bdo></b><th id='fQl0l'></th></span></q></dt></tr></i><div id='fQl0l'><tfoot id='fQl0l'></tfoot><dl id='fQl0l'><fieldset id='fQl0l'></fieldset></dl></div>

          <bdo id='fQl0l'></bdo><ul id='fQl0l'></ul>
        • <small id='fQl0l'></small><noframes id='fQl0l'>

          <tfoot id='fQl0l'></tfoot>

              <tbody id='fQl0l'></tbody>

              <legend id='fQl0l'><style id='fQl0l'><dir id='fQl0l'><q id='fQl0l'></q></dir></style></legend>

                1. 本文介绍了从字符串中解析多个双精度数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道如何从一个字符串中解析几个双数,但是字符串可以混合,例如:String s = "text 3.454 sometext5.567568more_text".

                  I would like to know how to parse several double numbers from a string, but string can be mixed, for instance: String s = "text 3.454 sometext5.567568more_text".

                  标准方法(Double.parseDouble)不合适.我尝试使用 isDigit 方法解析它,但是如何解析其他字符和 .?

                  The standard method (Double.parseDouble) is unsuitable. I've tried to parse it using the isDigit method, but how to parse other characters and .?

                  谢谢.

                  推荐答案

                  在使用此代码或其他帖子中的合适正则表达式解析双打后,迭代以将匹配的双打添加到列表中.在这里,您可以在代码中的其他任何地方使用 myDoubles.

                  After parsing your doubles with the suitable regular expressions like in this code or in other posts, iterate to add the matching ones to a list. Here you have myDoubles ready to use anywhere else in your code.

                  public static void main ( String args[] )
                  {
                      String input = "text 3.454 sometext5.567568more_text";
                      ArrayList < Double > myDoubles = new ArrayList < Double >();
                      Matcher matcher = Pattern.compile( "[-+]?\d*\.?\d+([eE][-+]?\d+)?" ).matcher( input );
                  
                      while ( matcher.find() )
                      {
                          double element = Double.parseDouble( matcher.group() );
                          myDoubles.add( element );
                      }
                  
                      for ( double element: myDoubles )
                          System.out.println( element );
                  }
                  

                  这篇关于从字符串中解析多个双精度数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <legend id='E97Gj'><style id='E97Gj'><dir id='E97Gj'><q id='E97Gj'></q></dir></style></legend>

                    <tfoot id='E97Gj'></tfoot>

                      • <i id='E97Gj'><tr id='E97Gj'><dt id='E97Gj'><q id='E97Gj'><span id='E97Gj'><b id='E97Gj'><form id='E97Gj'><ins id='E97Gj'></ins><ul id='E97Gj'></ul><sub id='E97Gj'></sub></form><legend id='E97Gj'></legend><bdo id='E97Gj'><pre id='E97Gj'><center id='E97Gj'></center></pre></bdo></b><th id='E97Gj'></th></span></q></dt></tr></i><div id='E97Gj'><tfoot id='E97Gj'></tfoot><dl id='E97Gj'><fieldset id='E97Gj'></fieldset></dl></div>

                            <bdo id='E97Gj'></bdo><ul id='E97Gj'></ul>

                            <small id='E97Gj'></small><noframes id='E97Gj'>

                              <tbody id='E97Gj'></tbody>