private ArrayList<String> parseJson(String text){
  text=text.substring(text.indexOf("\\nEvents\\n") + SIZE_OF_EVENTS,text.indexOf("\\n\\n\\nBirths"));
  ArrayList<String> events=new ArrayList<String>();
  if (text.isEmpty()) {
    return events;
  }
  int startIndex=0, endIndex=0;
  while (endIndex != -1) {
    endIndex=text.indexOf("\\n",startIndex + DELIMITER_SIZE);
    String eventText=(endIndex == -1 ? text.substring(startIndex) : text.substring(startIndex,endIndex));
    Pattern pattern=Pattern.compile("\\\\u2013\\s*");
    Matcher matcher=pattern.matcher(eventText);
    eventText=matcher.replaceAll("");
    pattern=Pattern.compile("(^\\d+)");
    matcher=pattern.matcher(eventText);
    if (matcher.find()) {
      eventText=matcher.replaceFirst(matcher.group(1) + ",");
    }
    eventText="In " + eventText;
    startIndex=endIndex + 2;
    events.add(eventText);
  }
  Collections.reverse(events);
  return events;
}

private ArrayList < String > parseJson ( String text ) { text = text . substring ( text . indexOf ( "\\nEvents\\n" ) + SIZE_OF_EVENTS , text . indexOf ( "\\n\\n\\nBirths" ) ) ; ArrayList < String > events = new ArrayList < String > ( ) ; if ( text . isEmpty ( ) ) { return events ; } int startIndex = 0 , endIndex = 0 ; while ( endIndex != - 1 ) { endIndex = text . indexOf ( "\\n" , startIndex + DELIMITER_SIZE ) ; String eventText = ( endIndex == - 1 ? text . substring ( startIndex ) : text . substring ( startIndex , endIndex ) ) ; Pattern pattern = Pattern . compile ( "\\\\u2013\\s*" ) ; Matcher matcher = pattern . matcher ( eventText ) ; eventText = matcher . replaceAll ( "" ) ; pattern = Pattern . compile ( "(^\\d+)" ) ; matcher = pattern . matcher ( eventText ) ; if ( matcher . find ( ) ) { eventText = matcher . replaceFirst ( matcher . group ( 1 ) + "," ) ; } eventText = "In " + eventText ; startIndex = endIndex + 2 ; events . add ( eventText ) ; } Collections . reverse ( events ) ; return events ; }
parse json - formatted list of events / births / deaths from wikipedia , extract list of events and split the events into a string array of individual events . run regex matchers to make the list pretty by adding a comma after the year to add a pause , and by removing a unicode char .
