- 523 名前:デフォルトの名無しさん mailto:sage [2008/01/29(火) 17:34:01 ]
- >>520
これをコピペしてコンパイルして自分で色々実験してみるがよろし。 あと、JavaのとPerlの正規表現はほぼ別物と考えた方がいい。 public class RegExp { public static void main(String args[]){ String patStr = null; String text = null; if(args.length <= 0) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Pattern: "); patStr = br.readLine(); System.out.print("Text : "); text = br.readLine(); } catch(IOException e) { e.printStackTrace(); } } else { patStr = args[0]; text = args[1]; } Pattern pattern = Pattern.compile( patStr ); Matcher matcher = pattern.matcher( text ); if(matcher.matches()==true) System.out.println("match"); else System.out.println("not match"); } }
|

|