-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitstrings.java
More file actions
31 lines (25 loc) · 849 Bytes
/
Splitstrings.java
File metadata and controls
31 lines (25 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//String manupluatlion
import java.util.Arrays;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Splitstrings {
public static void main(String[] args) {
String mystring = "Mississippi";
String[] splitstring = mystring.split("s");
String secondstring = mystring.substring(1,5);
Pattern p = Pattern.compile("Mi(.*?)pi");
//get everything betweetn Mi -- pi
//matcher sees if it can find anything
Matcher m = p.matcher(mystring);
System.out.println("::Pattern::\n");
while(m.find())
{
//does the loop while it finds them
System.out.println(m.group(1));
}
System.out.println("\n::Substring::\n");
System.out.println(secondstring);
System.out.println("\n::Split::\n");
System.out.println(Arrays.toString(splitstring));
}
}