????Java ??????????????????API????java.util.regex ??????????????????????????API??
???????????
??????????????????????????????????????????仰??????????????????????????磬??????????????????????е??????????????
??????????????
?????????????????Java????????????????????????????? http://
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String pattern = ".*http://.*";
????boolean matches = Pattern.matches(pattern?? text);
????System.out.println("matches = " + matches);
??????????????????м??????? http:// ?????????????????????????????????????(.com??.net ???)???????????????????? http:// ???????
????Java6 ?й????????????API
??????????????Java6 ?й????????????API??
????Pattern (java.util.regex.Pattern)
?????? java.util.regex.Pattern ??? Pattern?? ??Java???????API?е?????????????????????????????????Pattern ???
????Pattern.matches()
?????????????????????????????????????????????t??????Pattern.matches()?????????:
????String text    =
????"This is the text to be searched " +
????"for occurrences of the pattern.";
????String pattern = ".*is.*";
????boolean matches = Pattern.matches(pattern?? text);
????System.out.println("matches = " + matches);
???????????????? text ?в?????? “is” ???????????”is” ?????? 0???????(?? .* ???)
????Pattern.matches() ???????????? ??????????????г?????ε??????????????Pattern?????????á?
??????????????γ??????????????????????????????????????????á???????Pattern.compile() ??????????Pattern ?????
????Pattern.compile()
?????????????????????????????ж?γ??????????Pattern.compile() ???????????Pattern???????????
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String patternString = ".*http://.*";
????Pattern pattern = Pattern.compile(patternString);
??????????Compile ?????У???????????????
????Pattern pattern = Pattern.compile(patternString?? Pattern.CASE_INSENSITIVE);
????Pattern ???????????(int ????)????Щ??????????Pattern ???????????????????е???????????????Сд
????Pattern.matcher()
????????????Pattern?????????????Matcher????Matcher ??????????????е???.???????
????Matcher matcher = pattern.matcher(text);
????Matcher???????matches()??????????????????????????????????Matcher?????????????
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String patternString = ".*http://.*";
????Pattern pattern = Pattern.compile(patternString?? Pattern.CASE_INSENSITIVE);
????Matcher matcher = pattern.matcher(text);
????boolean matches = matcher.matches();
????System.out.println("matches = " + matches);
????Pattern.split()
????Pattern ??? split()?????????????????????????????????????String????????顣?????
????String text = "A sep Text sep With sep Many sep Separators";
????String patternString = "sep";
????Pattern pattern = Pattern.compile(patternString);
????String[] split = pattern.split(text);
????System.out.println("split.length = " + split.length);
????for(String element : split){
????System.out.println("element = " + element);
????}
?????????а?text ??????????????5????????????顣
????Pattern.pattern()
????Pattern ??? pattern ???????????Pattern ???????????????????
????String patternString = "sep";
????Pattern pattern = Pattern.compile(patternString);
????String pattern2 = pattern.pattern();
????????????? pattern2 ??sep ????patternString ?????????
????Matcher (java.util.regex.Matcher)
????java.util.regex.Matcher ????????????????ж?γ???????????????Matcher ?????????????????????????????
????Matcher ?к?????????????????ο????JavaDoc???????????????????
???????′????????????Matcher
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String patternString = ".*http://.*";
????Pattern pattern = Pattern.compile(patternString);
????Matcher matcher = pattern.matcher(text);
????boolean matches = matcher.matches();
??????????????Pattern???????Matcher ??????matches() ??????????true ????????????false????????
??????????Matcher ??????????
????????Matcher
???????Pattern ??matcher() ???????????Matcher??
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String patternString = ".*http://.*";
????Pattern pattern = Pattern.compile(patternString);
????Matcher matcher = pattern.matcher(text);
????matches()
????Matcher ??? matches() ?????????????????????????
????boolean matches = matcher.matches();
??????????????????????matches() ????????true????????false??
????matches() ????????????????????????γ?????????????????find()?? start() ?? end() ??????
????lookingAt()
????lookingAt() ??matches() ?????????????????lookingAt()???????????????????????????
????matches() ????????????????????????仰??????????????????????????????????????lookingAt() ????true????matches() ????false?? ?????
????String text    =
????"This is the text to be searched " +
????"for occurrences of the http:// pattern.";
????String patternString = "This is the";
????Pattern pattern = Pattern.compile(patternString?? Pattern.CASE_INSENSITIVE);
????Matcher matcher = pattern.matcher(text);
????System.out.println("lookingAt = " + matcher.lookingAt());
????System.out.println("matches   = " + matcher.matches());
????????????????????????????????????????? “this is the”. ??????????????(lookingAt()) ????true??
???????????????????????????? (matches()) ????false????? ??????????????????????? ???????????????????”this is the”???????????ж????????