question: public static String extractId ( String url ) { { Pattern u = Pattern . compile ( "youtube.com/watch?.*v=([^&]*)" ) ; Matcher um = u . matcher ( url . toString ( ) ) ; if ( um . find ( ) ) { return um . group ( 1 ) ; } } { Pattern u = Pattern . compile ( "youtube.com/v/([^&]*)" ) ; Matcher um = u . matcher ( url . toString ( ) ) ; if ( um . find ( ) ) { return um . group ( 1 ) ; } } return "" ; }
target:  extracts the youtube id from the given url