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£¬Í»Ò»Ð´ÆðÀ´£¬·¢ÏÖ»úÆ÷ÉÏûÓÐÉèÖû·¾³±äÁ¿£¬°ÑÉèÖ÷½·¨×ܽáÒ»ÏÂ
¡¡¡¡1. ÐÞ¸Ä/etc/profileÎļþ
¡¡¡¡¡¡¡¡Èç¹ûÄãµÄ¼ÆËã»ú½ö½ö×÷Ϊ¿ª·¢Ê¹ÓÃʱÍƼöʹÓÃÕâÖÖ·½·¨£¬ÒòΪËùÓÐÓû§µÄshell¶¼ÓÐȨʹÓÃÕâЩ»·¾³±äÁ¿£¬¿ÉÄÜ»á¸øϵͳ´øÀ´°²È«ÐÔÎÊÌâ¡£
¡¡¡¡¡¡¡¡·ÓÃÎı¾±à¼Æ÷´ò¿ª/etc/profile
¡¡¡¡¡¡¡¡·ÔÚpr ......
try {
Runtime.getRuntime().exec("C:\\xxx.exe");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} ......
Ñ¡ÔñjavaºóµÄÄÇЩÊÂ…
ÕâÁ½ÌìѧУ¿ªÊ¼ÈÃÎÒÃÇÕâÒ»´óÅú¸ß·ÑÉúÑ¡Ôñ×Ô¼ºµÄרҵ·½Ïò£¬FocuserÎÒ¾¹ýºÃ¼¸¸öÄêÍ·µÄ˼¿¼£¬²¢ÇÒÔÚÎÒÃÇÇ×°®c#ÀÏʦÈÈÇéµÄÏòÎÒÃǽéÉÜ.netµÄÇ°¾°ºó£¬ÒãÈ»¼á¶¨µÄÑ¡ÔñÁËjavaÕâÌõ×Ô¼ºÈÏΪǰ³ÌËƽõµÄµÀ·¡£ÒÔϵÄÕâЩÍøÕ¾ÊÇÎÒƽʱ¾³£·ÃÎʵÄһЩ¹úÍâµÄÓ¢ÎÄjavaÍøÕ¾£¬½ñÌìÌصصķ¢²¼¸ø´ó¼Ò£¬Ï£ÍûÎÒÃÇÄ ......
http://hi.baidu.com/0_net/blog/item/8566fc2bb730c293033bf63e.html
Ò».»ñµÃ¿ØÖÆ̨Óû§ÊäÈëµÄÐÅÏ¢
/** *//**»ñµÃ¿ØÖÆ̨Óû§ÊäÈëµÄÐÅÏ¢
* @return
* @throws IOException
*/
public St ......