Skip to content

Commit 219f951

Browse files
author
Liu Yuning
committed
add using regex
1 parent 52ef2f3 commit 219f951

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/basic/UsingRegex.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package basic;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
/**
7+
* 使用正则表达式
8+
*
9+
* @Todo 正则表达式复杂的用法
10+
* @author liu yuning
11+
*
12+
*/
13+
public class UsingRegex {
14+
public static void main(String[] args) {
15+
String regexSample = "\\w+";
16+
String inputString = "123";
17+
18+
Pattern pattern = Pattern.compile(regexSample);
19+
Matcher matcher = pattern.matcher(inputString);
20+
21+
System.out.println(matcher.matches());
22+
23+
}
24+
}

0 commit comments

Comments
 (0)