Skip to content

Commit 3f49e57

Browse files
author
crazy
committed
2 parents 827f90a + bbe55a1 commit 3f49e57

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

JavaBase/src/com/xinan/exception/Exception01.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void main(String[] args) {
1515
ae.printStackTrace();
1616
System.out.println("ArithmeticException被捕获");
1717
} catch (InputMismatchException ime) {
18-
ime.printStackTrace();
18+
//ime.printStackTrace();
1919
//System.out.println(ime.getMessage());
2020
//System.out.println("InputMismatchException被捕获");
2121
} catch (Exception e) {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xinan.regex;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
public class RegexDemo01 {
7+
8+
public static void main(String[] args) {
9+
/*
10+
* // TODO Auto-generated method stub String content
11+
* ="i am noob"+"from runoo0b.com."; String pattern=".*runoob.*";
12+
* boolean isMatch=Pattern.matches(pattern, content);
13+
* System.out.println(isMatch);
14+
*/
15+
/*String str = "[email protected]";
16+
String regEx = "^[a-zA-Z_]{1,}[0-9]{0,}@(([a-zA-z0-9]-*){1,}\\.){1,3}[a-zA-z\\-]{1,}$ ";// 此处写匹配规则
17+
*/ Pattern p = Pattern.compile("\\d{4}");
18+
Matcher m = p.matcher("hello235216asdasdas48512");
19+
/*System.out.println(m.matches());// 匹配所有
20+
System.out.println(m.find());// 匹配所有
21+
*/ while(m.find()){
22+
System.out.println(m.group());
23+
}
24+
}
25+
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xinan.string01;
2+
3+
public class StringDemo01 {
4+
public static void main(String[] args) {
5+
String fileNames = "abc.java;hello.will.txt;hello.java;hello.class";
6+
/*
7+
* String s1 = new String("abcd");
8+
*
9+
* System.out.println(s == s1); System.out.println(s.trim());
10+
* System.out.println(s.replace('a', 'b'));
11+
* System.out.println(s.indexOf('b')); System.out.println(s.length());
12+
*
13+
* System.out.println(s.charAt(5)); System.out.println(s.isEmpty());
14+
* System.out.println(s.indexOf('a'));
15+
*/
16+
String[] names = fileNames.split(";");
17+
for (String name : names) {
18+
if (name.startsWith("hello")) {
19+
int index = name.lastIndexOf(".");
20+
String newName = name.substring(index);
21+
System.out.println(newName);
22+
}
23+
}
24+
}
25+
26+
}

0 commit comments

Comments
 (0)