JAVA開発メモ

 

[リロード]   [新規|編集|差分|添付]   [トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]

サイトメニュー

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); Matcher m = p.matcher(st); String replaced = m.replaceAll(""); 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
Last-modified: Tue, 24 Feb 2009 04:16:40 UTC (4833d)
Link: (4987d)

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.031 sec.