★★ Java の宿題ここ ..
[2ch|▼Menu]
55:Indooroopilly
09/07/27 22:15:31
import java.util.Scanner;
import java.util.regex.*;
public class KeywordExtractor{

public static void main(String [] args)throws Exception{

String keyword = "q=([^&]+)";
Pattern pattern = Pattern.compile(keyword);

System.out.print("Input URL: ");
Scanner scan = new Scanner(System.in);
Matcher matcher;
String line = "";
while(scan.hasNext()){
line = scan.nextLine();
matcher = pattern.matcher(line);
if(matcher.find()){
String foundWord = matcher.group().replaceAll("q=", "");
System.out.println("Keyword: " + foundWord);
}else{
System.out.println("Did not find any keyword in the text.");
}
matcher.reset();
System.out.print("Try other URL: ");
}
}
}


次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5051日前に更新/316 KB
担当:undef