-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegex.java
More file actions
23 lines (19 loc) · 664 Bytes
/
Copy pathRegex.java
File metadata and controls
23 lines (19 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.io.*;
import java.util.regex.*;
public class Regex{
public static void main(String[] args){
{
String line = "STRING";
Pattern pattern = Pattern.compile("S.R");
Matcher matcher = pattern.matcher(line);
if(matcher.find()) {
System.out.println(line);
System.out.println("Found '" + matcher.group() +
"' starting at index " + matcher.start() +
" and ending at index " + matcher.end() + ".");
}else{
System.out.println("*** NO MATCH ***");
}
}
}
}