BatCave1997
7/23/2018 - 4:56 AM

String Manipulation

string.split() Pattern and Matcher

public void stringManipulation{
  
  String s = "My Name Is Sarthak"
  String[] splitPage  = s.split("Is");
  System.out.println(spliPage[0]);
  
  
  Pattern p = Pattern.compile("M"(.*?)\"t");
  Matcher m = p.matcher(splitPage[0]);
  
  while(m.find()){
    System.out.println(m.group(1));// excluding 'M' and 't'
    System.out.println(m.group(0));// including 'M' and 't'
    }
  }