?? useregularexpression.java
字號:
import java.io.*;
public class UseRegularExpression {
public static void main(String args[])
throws IOException {
BufferedReader reader =
new BufferedReader(
new InputStreamReader(System.in));
System.out.println("abcdefgabcabc".replaceAll(".bc", "###"));
String phoneEL = "[0-9]{4}-[0-9]{6}";
String urlEL = "<a.+href*=*['\"]?.*?['\"]?.*?>";
String emailEL = "^[_a-z0-9-]+(.[_a-z0-9-]+)*" +
"@[a-z0-9-]+(.[a-z0-9-]+)*$";
System.out.print("輸入手機(jī)號碼: ");
String input = reader.readLine();
if(input.matches(phoneEL))
System.out.println("格式正確");
else
System.out.println("格式錯(cuò)誤");
System.out.print("輸入href標(biāo)簽: ");
input = reader.readLine();
// 驗(yàn)證href標(biāo)簽
if(input.matches(urlEL))
System.out.println("格式正確");
else
System.out.println("格式錯(cuò)誤");
System.out.print("輸入電子郵件: ");
input = reader.readLine();
//驗(yàn)證電子郵件格式
if(input.matches(emailEL))
System.out.println("格式正確");
else
System.out.println("格式錯(cuò)誤");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -