question: 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 ; }
target:  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.