JavaÕýÔò±í´ïʽһ
¹Ø¼ü×Ö: java regex, regular expression
ÕýÔò±í´ïʽÔÚ´¦ÀíÎı¾·½ÃæÓô¦·Ç³£´ó£¬×îÔçÏñÔÚPerlºÍawkÓïÑÔÖУ¬ÌṩÁËÕâÖÖ»úÖÆ£¬JavaÔÚJava 2ÖÐÒ²Ôö¼ÓÁËÕýÔò±í´ïʽÕâ¸ö°üjava.util.regex¡£Õâ¸ö°üΪÓû§Ê¹ÓÃÕýÔò±í´ïʽ£¬ÌṩÁËÒ×ÓöøÈ«ÃæµÄÖ§³Ö¡£ÎÒµÄÑо¿·½ÏòÊÇwebÍÚ¾ò¡£´ÓÍøÒ³ÖÐÌáÈ¡ÄÚÈÝ,´¦ÀíÎı¾£¬µ±È»ÐèÒªÕýÔò±í´ïʽÕâ¸öÇ¿´óµÄ¹¤¾ßÁË¡£
Ò»¡¢Ê×ÏÈÎÒÃÇ¿´Ò»ÏÂÔõôʹÓÃÕýÔò±í´ïʽµÄÒ»¸öÀý×Ó£º
A Matcher examines the results of applying a pattern.
ÎÒÃÇÏ£Íû´ÓÕâ¾ä»°ÖÐÕÒµ½ËùÓпªÍ·ÎªaµÄµ¥´Ê¡£
µ±È»ÕâÖ»ÊÇÒ»¸ö¼òµ¥µÄÀý×Ó£¬Äã¿ÉÒÔʹÓÃStringÌṩµÄsplit·½·¨£¬µÃµ½µ¥´ÊÊý×飬Ȼºó
±éÀú¸÷¸öµ¥´Ê¿´ÊÇ·ñÊÇ·ñ¿ªÍ·Îªa
ÎÒÃÇÏÖÔÚ¿´¿´ÔõôʹÓÃÕýÔò±í´ïʽÀ´´¦ÀíÕâ¸öÎÊÌ⣺
Java´úÂë
import java.util.regex.*;
public class FindA{
public static void main(String args[])
throws Exception{
String candidate =
"A Matcher examines the results of applying a pattern.";
String regex = "\\ba\\w*\\b";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(candidate);
String val = null;
System.out.println("INPUT: " + candidate);
System.out.println("REGEX: " + regex +"\r\n");
while (m.find()){
val = m.group();
System.out.println("MATCH: " + val);
}
if (val == null) {
&nb
Ïà¹ØÎĵµ£º
JAVA finally×Ö¾äµÄÒì³£¶ªÊ§ºÍ·µ»ØÖµ¸²¸Ç½âÎö
JavaÐéÄâ»úÔÚÿ¸ötryÓï¾ä¿éºÍÓëÆäÏà¹ØµÄcatch×Ó¾äµÄ½áβ
´¦¶¼»á“µ÷ÓÔfinally×Ó¾äµÄ×ÓÀý³Ì¡£Êµ¼ÊÉÏ£¬finally×Ó¾äÔÚ·½·¨ÄÚ²¿µÄ±íÏÖºÜÏó“΢ÐÍ×ÓÀý³Ì”¡£finally×Ó¾äÕý³£½áÊøºó£Ö¸µÄÊÇfinally×Ó¾äÖÐ×îºóÒ»ÌõÓï¾äÕý³£Ö´ÐÐÍê±Ï£¬²»°üÀ¨Å׳öÒì³££¬»òÖ´ÐÐre ......
¹úÍâÖøÃûjava¼¼Êõ×ÊÁÏÍøÕ¾
¹úÍâÖøÃûjava¼¼Êõ×ÊÁÏÍøÕ¾
http://www.onjava.com
O'ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ
http://java.sun.com
¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ - ÿÖܶ¼ÓÐÐÂÎÄÕ·¢±í
http://www.developer.com/java
Ó ......
Ñ¡ÔñjavaºóµÄÄÇЩÊÂ…
ÕâÁ½ÌìѧУ¿ªÊ¼ÈÃÎÒÃÇÕâÒ»´óÅú¸ß·ÑÉúÑ¡Ôñ×Ô¼ºµÄרҵ·½Ïò£¬FocuserÎÒ¾¹ýºÃ¼¸¸öÄêÍ·µÄ˼¿¼£¬²¢ÇÒÔÚÎÒÃÇÇ×°®c#ÀÏʦÈÈÇéµÄÏòÎÒÃǽéÉÜ.netµÄǰ¾°ºó£¬ÒãÈ»¼á¶¨µÄÑ¡ÔñÁËjavaÕâÌõ×Ô¼ºÈÏΪǰ³ÌËÆ½õµÄµÀ·¡£ÒÔϵÄÕâÐ©ÍøÕ¾ÊÇÎÒÆ½Ê±¾³£·ÃÎʵÄһЩ¹úÍâµÄÓ¢ÎÄjavaÍøÕ¾£¬½ñÌìÌØµØµÄ·¢²¼¸ø´ó¼Ò£¬Ï£ÍûÎÒÃÇÄ ......
JavaÎÊÌâ¾µä32ÎÊ
µÚÒ»£¬Ì¸Ì¸final£¬ finally£¬ finalizeµÄÇø±ð¡£
µÚ¶þ£¬Anonymous Inner Class £¨ÄäÃûÄÚ²¿Àࣩ ÊÇ·ñ¿ÉÒÔextends£¨¼Ì³Ð£©ÆäËüÀ࣬ÊÇ·ñ¿ÉÒÔimplements£¨ÊµÏÖ£©interface£¨½Ó¿Ú£©£¿
µÚÈý£¬Static Nested Class ºÍ Inner ClassµÄ²»Í¬£¬ËµµÃÔ½¶àÔ½ºÃ£¨ÃæÊÔÌâÓе ......
package com.sy.grasp;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpression {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
......