正则啊正则!

无敌简单的正则,我换了很多方法都不正确,郁闷

1,找出匹配 单词create 加任意空格或换行或回车 加单词procedure 后面可以有任意字符串

我写的是 .matches("create(\n|\r|\b)*"procedure[.\n]")

2,找出specific这个单词后的 一个单词,我考虑用空格来取出这个单词
谁能帮帮我???

谢谢啦

[code="java"]
package net.sulin.regular;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularWord {

public static void main(String[] args) {

    String test = "fsf$ specific $ test@#$dfsdff@3";
    String first = null;
    String end = null;
    Pattern p = null;
    Matcher m = null;
    //第一次提取
    p = Pattern.compile("specific[^a-zA-Z]+([a-zA-Z]+)");
    m = p.matcher(test);   
    while (m.find()){
        String temp = m.group();
        first = temp.substring("specific".length(), temp.length());   
    }
    //第二次提取
    p = Pattern.compile("[^a-zA-Z]+");
    m = p.matcher(first); 
    while (m.find()){
        String temp = m.group();
        System.out.println(temp.length());
        end = first.substring(temp.length(), first.length());
    }

    System.out.println(end);

}

}

[/code]
:P :P 上午看NCAA、 闲着没事干, 就帮你贴一个完整的程序吧

.*[^a-zA-Z]*specific[^a-zA-Z]+([a-zA-Z]+)[^a-zA-Z]*.*
:x :x
这个应该可以
.*[^a-zA-Z]* 匹配开始的任意字符和单词之间的分隔字符(任意非字母字符)
specific[^a-zA-Z]+ 匹配specific和单词之间的分隔字符(任意非字母字符)
+([a-zA-Z]+) 匹配你要提取的单词
[^a-zA-Z]*.* 匹配你要提取的单词之后的单词之间的分隔字符(任意非字母字符)和结束的任意字符
:P :P 找到答案了吧

.*[^a-zA-Z]+specific[^a-zA-Z]+([a-zA-Z]+)[^a-zA-Z]+.*
修改了一下, 应该这样。 单词之间的分隔字符必须存在至少一个

create\s+procedure
(?<=specific[\s+])[a-z]+

[code="java"]

Pattern pattern = Pattern.compile("(create).*(procedure).*");
Matcher matcher = pattern.matcher(str);
if(matcher.matches()){

}else{

}

[/code]