Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 2
指定された文字列の置換 | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 17
指定された文字列の置換
文字列中のある文字を、別の文字に置換したい場合、StringクラスのreplaceAllメソッドを使用します。
このメソッドは、文字列中に複数個置換したい文字がある場合に全部指定した文字に置換してくれます。

以下のクラスでは、文字列"test1¥ntest2¥n"の中の"¥n"を","に変更して文字列を出力しています。
"¥n"は文字列中に2箇所ありますが、両方とも","に置換されます。

public class test {
    public static void main (String args[]){
        System.out.println("test1¥ntest2¥n".replaceAll("¥n",","));
    }
}
上記、Javaアプリケーションを実行すると結果は以下のようになります。

test1,test2,
となります。

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 70

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 70

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 79

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/string/replace_all/replace_all.html on line 79