Skip to content

Instantly share code, notes, and snippets.

@Bahaaib
Last active June 11, 2017 22:22
Show Gist options
  • Select an option

  • Save Bahaaib/64ca0699dae6115f9b5cd824e1df7da6 to your computer and use it in GitHub Desktop.

Select an option

Save Bahaaib/64ca0699dae6115f9b5cd824e1df7da6 to your computer and use it in GitHub Desktop.
String Manipulation further more..
import java.util.Arrays;
import java.util.Pattern;
import java.util.Matcher;
public class HelloWorld {
public static main (String[] args){
String mystring = "Mississippi";
String [] splitter = mystring.split("s"); // to split the phrase to words depends on a specific letter
String riverPart = mystring.substring(2, 5); // to prints the letters starting from letter 2 to 5 "which is not including"
Pattern p = Pattern.compile("Mi(.*?)pi"); // REGEX code to find a pattern of letters
Matcher m = p.Matcher(mystring);
while(m.find()){
System.out.println(m.group(1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment