Buggy code:
public class RecordBookExtractor implements RecordBookExtractorInterface { @ Override public RecordBook getExamsList ( String targetUrl , String username , String password ) throws UnirestException { } private RecordBook extractRecordBook ( String targetURL ) { List < Exam > exams = new ArrayList < Exam > ( ) ; Document doc = Jsoup . parse ( targetURL ) ; Elements tplMasterCells = doc . select ( "td[class=tplMaster]" ) ; String averageString = "0" ; String weightedAverageString = "0" ; if ( ( tplMasterCells != null ) && ( ( tplMasterCells . size ( ) ) == 2 ) ) { averageString = tplMasterCells . get ( 0 ) . text ( ) ; weightedAverageString = tplMasterCells . get ( 1 ) . text ( ) ; averageString = averageString . replaceAll ( "[^0-9\\.]" , "" ) ; weightedAverageString = weightedAverageString . replaceAll ( "[^0-9\\.]" , "" ) ; averageString = averageString . substring ( 0 , ( ( averageString . length ( ) ) - 2 ) ) ; weightedAverageString = weightedAverageString . substring ( 0 , ( ( weightedAverageString . length ( ) ) - 2 ) ) ; } double average = Double . parseDouble ( averageString ) ; double weightedAverage = Double . parseDouble ( weightedAverageString ) ; Elements detailTableRows = doc . select ( "table[class=detail_table]<seq2seq4repair_space>tr" ) ; if ( ( detailTableRows == null ) || ( ( detailTableRows . size ( ) ) == 0 ) ) { return new RecordBook ( exams , average , weightedAverage ) ; } for ( Element row : detailTableRows ) { Elements cells = row . select ( "td" ) ; if ( ( cells == null ) || ( ( cells . size ( ) ) == 0 ) ) { continue ; } Element link = cells . get ( 1 ) . child ( 0 ) ; String linkString = link . attr ( "href" ) ; <START_BUG> Pattern adsceIdPattern = Pattern . compile ( "adsce_id=[0-9]{7}\\&" ) ; <END_BUG> Matcher m = adsceIdPattern . matcher ( linkString ) ; String adsceId = "" ; while ( m . find ( ) ) { adsceId = m . group ( 0 ) ; } adsceId = adsceId . replace ( "adsce_id=" , "" ) ; adsceId = adsceId . replace ( "&" , "" ) ; String name = StringUtils . realTrim ( link . text ( ) ) ; String cfuString = "0" ; int cfu = 0 ; Element cfuCell = cells . get ( 6 ) ; if ( cfuCell != null ) { cfuString = StringUtils . realTrim ( cfuCell . text ( ) ) ; cfu = Integer . parseInt ( cfuString ) ; } String grade = "//" ; Date date = new Date ( ) ; Element gradeDateCell = cells . get ( 9 ) ; if ( gradeDateCell != null ) { String gradeDate = StringUtils . realTrim ( gradeDateCell . text ( ) ) ; gradeDate = gradeDate . replace ( 'Â' , '<seq2seq4repair_space>' ) ; gradeDate = gradeDate . replace ( '<seq2seq4repair_space>' , '<seq2seq4repair_space>' ) ; String [ ] bits = gradeDate . split ( "<seq2seq4repair_space>-<seq2seq4repair_space>" ) ; if ( ( bits . length ) == 2 ) { grade = bits [ 0 ] ; SimpleDateFormat sdf = new SimpleDateFormat ( "dd//MM//yyyy" ) ; try { date = sdf . parse ( bits [ 1 ] ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } } } String academicYear = "//" ; Element academicYearCell = cells . get ( 8 ) ; if ( academicYearCell != null ) { academicYear = StringUtils . realTrim ( academicYearCell . text ( ) ) ; } Exam exam = new Exam ( name , cfu , grade , date , academicYear , adsceId ) ; exams . add ( exam ) ; } RecordBook recordBook = new RecordBook ( exams , average , weightedAverage ) ; return recordBook ; } }

Fix:
Pattern adsceIdPattern = Pattern . compile ( "adsce_id=[0-9]+\\&" ) ;