JAVA開発メモ
のバックアップ(No.2)
 

[トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]


String text = "Hello World!"; Pattern p = Pattern.compile("Hello"); Matcher m = p.matcher(text); if (m.find()) { } else { } String text = "www.hoge.net"; Pattern p = Pattern.compile("\\.net"); Matcher m = p.matcher(text); String replaced = m.replaceFirst(".info"); System.out.println(replaced); String text = "Name: Regular Expressions"; Pattern p = Pattern.compile("^(\\w+):\\s+(.+)$"); Matcher m = p.matcher(text); if (m.find()) { String key = m.group(1); // key = "Name"; String value = m.group(2); // value = "Regular Expressions"; System.out.println("key = " + key); System.out.println("value = " + value); } String text = "<a href=\"http://www.hoge.net/\">HOGE</a>"; String replaced = text.replaceFirst("<a href=\"(.+?)\">(.+?)</a>", System.out.println(replaced); Pattern p = Pattern.compile("(\\p{InBasicLatin}+|" + " \\p{InHiragana}+|" + " \\p{InKatakana}+|" + " \\p{InCJKUnifiedIdeographs}+)", Pattern.COMMENTS); Matcher m = p.matcher(text); while (m.find()) { String chunk = m.group(1); System.out.println(chunk); } String replaced = text.replaceAll("<.+?>", ""); System.out.println(replaced);
トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.28

HTML convert time to 0.029 sec.