<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 題目 – 檢查字符串是否完整(包含所有字母) > 原文: [https://howtodoinjava.com/puzzles/puzzle-check-if-string-is-complete-contains-all-alphabets/](https://howtodoinjava.com/puzzles/puzzle-check-if-string-is-complete-contains-all-alphabets/) 如果字符串包含從 a 到 z 的所有字符,則認為該字符串是完整的。 給定一個字符串,檢查它是否完整。 例如: **示例輸入** ```java 3 wyyga qwertyuioplkjhgfdsazxcvbnm ejuxggfsts ``` **示例輸出** ```java NO YES NO ``` ## 使用`for`循環和`indexOf()`的解決方案 我寫了一個簡單的函數,可以找到這個完整的字符串。 ```java package com.howtodoinjava.examples; public class CheckAllAlphabetsAlgorithms { public static void main(String[] args) { System.out.println( checkAllChars( "qwertyuioplkjhgfdsAzxcvbnm" ) ); System.out.println( checkAllChars( "123" ) ); System.out.println( checkAllChars( "ejuxggfsts" ) ); System.out.println( checkAllChars( "wyyga" ) ); } private static String checkAllChars ( String input ) { //If input length is less than 26 then it can never be complete if(input.length() < 26) { return "FALSE"; } for (char ch = 'A'; ch <= 'Z'; ch++) { if (input.indexOf(ch) < 0 && input.indexOf((char) (ch + 32)) < 0) { return "FALSE"; } } return "TRUE"; } } ``` **輸出**: ```java TRUE FALSE FALSE FALSE ``` ## 用于正則表達式的解決方案 這是一個使用正則表達式查找完整字符串的解決方案(很丑,因為我不喜歡長的正則表達式)。 ```java package com.howtodoinjava.examples; public class CheckAllAlphabetsAlgorithms { public static void main(String[] args) { System.out.println( checkAllCharsUsingRegex( "qwertyuioplkjhgfdsAzxcvbnm" ) ); System.out.println( checkAllCharsUsingRegex( "123" ) ); System.out.println( checkAllCharsUsingRegex( "ejuxggfsts" ) ); System.out.println( checkAllCharsUsingRegex( "wyyga" ) ); } private static String checkAllCharsUsingRegex ( String input ) { //If input length is less than 26 then it can never be complete if(input.length() < 26) { return "FALSE"; } String regex = "(?i)(?=.*a)(?=.*b)(?=.*c)(?=.*d)(?=.*e)(?=.*f)" + "(?=.*g)(?=.*h)(?=.*i)(?=.*j)(?=.*k)(?=.*l)(?=.*m)(?=.*n)" + "(?=.*o)(?=.*p)(?=.*q)(?=.*r)(?=.*s)(?=.*t)(?=.*u)(?=.*v)" + "(?=.*w)(?=.*x)(?=.*y)(?=.*z).*"; if(input.matches(regex)){ return "TRUE"; } return "FALSE"; } } ``` **輸出**: ```java TRUE FALSE FALSE FALSE ``` **祝您學習愉快!**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看