@Test public void testExtractUrls() { assertUrlsAre("hello http: assertUrlsAre("http: assertUrlsAre("hello http: "http: assertUrlsAre("hello https: "https: }
static LinkedHashSet<CharSequence> extractUrls(String text) { StringBuilder regex_sb = new StringBuilder(); regex_sb.append("("); regex_sb.append("(?:"); regex_sb.append("dav|"); regex_sb.append("dict|"); regex_sb.append("dns|"); regex_sb.append("file|"); regex_sb.append("finger|"); regex_sb.append("ftp(?:s?)|"); regex_sb.append("git|"); regex_sb.append("gopher|"); regex_sb.append("http(?:s?)|"); regex_sb.append("imap(?:s?)|"); regex_sb.append("irc(?:[6s]?)|"); regex_sb.append("ip[fn]s|"); regex_sb.append("ldap(?:s?)|"); regex_sb.append("pop3(?:s?)|"); regex_sb.append("redis(?:s?)|"); regex_sb.append("rsync|"); regex_sb.append("rtsp(?:[su]?)|"); regex_sb.append("sftp|"); regex_sb.append("smb(?:s?)|"); regex_sb.append("smtp(?:s?)|"); regex_sb.append("svn(?:(?:\\+ssh)?)|"); regex_sb.append("tcp|"); regex_sb.append("telnet|"); regex_sb.append("tftp|"); regex_sb.append("udp|"); regex_sb.append("vnc|"); regex_sb.append("ws(?:s?)"); regex_sb.append("): regex_sb.append(")"); regex_sb.append("("); regex_sb.append("(?:\\S+(?::\\S*)?@)?"); regex_sb.append("(?:"); regex_sb.append("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|"); regex_sb.append("(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))?|"); regex_sb.append("/(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"); regex_sb.append(")"); regex_sb.append("(?::\\d{1,5})?"); regex_sb.append("(?:/[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append("(?:#[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append(")"); final Pattern urlPattern = Pattern.compile( regex_sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); LinkedHashSet<CharSequence> urlSet = new LinkedHashSet<>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); String url = text.substring(matchStart, matchEnd); urlSet.add(url); } return urlSet; }
TermuxActivity extends Activity implements ServiceConnection { static LinkedHashSet<CharSequence> extractUrls(String text) { StringBuilder regex_sb = new StringBuilder(); regex_sb.append("("); regex_sb.append("(?:"); regex_sb.append("dav|"); regex_sb.append("dict|"); regex_sb.append("dns|"); regex_sb.append("file|"); regex_sb.append("finger|"); regex_sb.append("ftp(?:s?)|"); regex_sb.append("git|"); regex_sb.append("gopher|"); regex_sb.append("http(?:s?)|"); regex_sb.append("imap(?:s?)|"); regex_sb.append("irc(?:[6s]?)|"); regex_sb.append("ip[fn]s|"); regex_sb.append("ldap(?:s?)|"); regex_sb.append("pop3(?:s?)|"); regex_sb.append("redis(?:s?)|"); regex_sb.append("rsync|"); regex_sb.append("rtsp(?:[su]?)|"); regex_sb.append("sftp|"); regex_sb.append("smb(?:s?)|"); regex_sb.append("smtp(?:s?)|"); regex_sb.append("svn(?:(?:\\+ssh)?)|"); regex_sb.append("tcp|"); regex_sb.append("telnet|"); regex_sb.append("tftp|"); regex_sb.append("udp|"); regex_sb.append("vnc|"); regex_sb.append("ws(?:s?)"); regex_sb.append("): regex_sb.append(")"); regex_sb.append("("); regex_sb.append("(?:\\S+(?::\\S*)?@)?"); regex_sb.append("(?:"); regex_sb.append("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|"); regex_sb.append("(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))?|"); regex_sb.append("/(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"); regex_sb.append(")"); regex_sb.append("(?::\\d{1,5})?"); regex_sb.append("(?:/[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append("(?:#[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append(")"); final Pattern urlPattern = Pattern.compile( regex_sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); LinkedHashSet<CharSequence> urlSet = new LinkedHashSet<>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); String url = text.substring(matchStart, matchEnd); urlSet.add(url); } return urlSet; } }
TermuxActivity extends Activity implements ServiceConnection { static LinkedHashSet<CharSequence> extractUrls(String text) { StringBuilder regex_sb = new StringBuilder(); regex_sb.append("("); regex_sb.append("(?:"); regex_sb.append("dav|"); regex_sb.append("dict|"); regex_sb.append("dns|"); regex_sb.append("file|"); regex_sb.append("finger|"); regex_sb.append("ftp(?:s?)|"); regex_sb.append("git|"); regex_sb.append("gopher|"); regex_sb.append("http(?:s?)|"); regex_sb.append("imap(?:s?)|"); regex_sb.append("irc(?:[6s]?)|"); regex_sb.append("ip[fn]s|"); regex_sb.append("ldap(?:s?)|"); regex_sb.append("pop3(?:s?)|"); regex_sb.append("redis(?:s?)|"); regex_sb.append("rsync|"); regex_sb.append("rtsp(?:[su]?)|"); regex_sb.append("sftp|"); regex_sb.append("smb(?:s?)|"); regex_sb.append("smtp(?:s?)|"); regex_sb.append("svn(?:(?:\\+ssh)?)|"); regex_sb.append("tcp|"); regex_sb.append("telnet|"); regex_sb.append("tftp|"); regex_sb.append("udp|"); regex_sb.append("vnc|"); regex_sb.append("ws(?:s?)"); regex_sb.append("): regex_sb.append(")"); regex_sb.append("("); regex_sb.append("(?:\\S+(?::\\S*)?@)?"); regex_sb.append("(?:"); regex_sb.append("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|"); regex_sb.append("(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))?|"); regex_sb.append("/(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"); regex_sb.append(")"); regex_sb.append("(?::\\d{1,5})?"); regex_sb.append("(?:/[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append("(?:#[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append(")"); final Pattern urlPattern = Pattern.compile( regex_sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); LinkedHashSet<CharSequence> urlSet = new LinkedHashSet<>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); String url = text.substring(matchStart, matchEnd); urlSet.add(url); } return urlSet; }  }
TermuxActivity extends Activity implements ServiceConnection { static LinkedHashSet<CharSequence> extractUrls(String text) { StringBuilder regex_sb = new StringBuilder(); regex_sb.append("("); regex_sb.append("(?:"); regex_sb.append("dav|"); regex_sb.append("dict|"); regex_sb.append("dns|"); regex_sb.append("file|"); regex_sb.append("finger|"); regex_sb.append("ftp(?:s?)|"); regex_sb.append("git|"); regex_sb.append("gopher|"); regex_sb.append("http(?:s?)|"); regex_sb.append("imap(?:s?)|"); regex_sb.append("irc(?:[6s]?)|"); regex_sb.append("ip[fn]s|"); regex_sb.append("ldap(?:s?)|"); regex_sb.append("pop3(?:s?)|"); regex_sb.append("redis(?:s?)|"); regex_sb.append("rsync|"); regex_sb.append("rtsp(?:[su]?)|"); regex_sb.append("sftp|"); regex_sb.append("smb(?:s?)|"); regex_sb.append("smtp(?:s?)|"); regex_sb.append("svn(?:(?:\\+ssh)?)|"); regex_sb.append("tcp|"); regex_sb.append("telnet|"); regex_sb.append("tftp|"); regex_sb.append("udp|"); regex_sb.append("vnc|"); regex_sb.append("ws(?:s?)"); regex_sb.append("): regex_sb.append(")"); regex_sb.append("("); regex_sb.append("(?:\\S+(?::\\S*)?@)?"); regex_sb.append("(?:"); regex_sb.append("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|"); regex_sb.append("(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))?|"); regex_sb.append("/(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"); regex_sb.append(")"); regex_sb.append("(?::\\d{1,5})?"); regex_sb.append("(?:/[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append("(?:#[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append(")"); final Pattern urlPattern = Pattern.compile( regex_sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); LinkedHashSet<CharSequence> urlSet = new LinkedHashSet<>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); String url = text.substring(matchStart, matchEnd); urlSet.add(url); } return urlSet; }  boolean ensureStoragePermissionGranted(); @Override void onCreate(Bundle bundle); @Override void onServiceConnected(ComponentName componentName, IBinder service); void switchToSession(boolean forward); @Override void onServiceDisconnected(ComponentName name); @Override void onStart(); @Override void onBackPressed(); @Override void onDestroy(); @Override void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onContextItemSelected(MenuItem item); @Override void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults); TerminalSession getStoredCurrentSessionOrLast(); void removeFinishedSession(TerminalSession finishedSession); }
TermuxActivity extends Activity implements ServiceConnection { static LinkedHashSet<CharSequence> extractUrls(String text) { StringBuilder regex_sb = new StringBuilder(); regex_sb.append("("); regex_sb.append("(?:"); regex_sb.append("dav|"); regex_sb.append("dict|"); regex_sb.append("dns|"); regex_sb.append("file|"); regex_sb.append("finger|"); regex_sb.append("ftp(?:s?)|"); regex_sb.append("git|"); regex_sb.append("gopher|"); regex_sb.append("http(?:s?)|"); regex_sb.append("imap(?:s?)|"); regex_sb.append("irc(?:[6s]?)|"); regex_sb.append("ip[fn]s|"); regex_sb.append("ldap(?:s?)|"); regex_sb.append("pop3(?:s?)|"); regex_sb.append("redis(?:s?)|"); regex_sb.append("rsync|"); regex_sb.append("rtsp(?:[su]?)|"); regex_sb.append("sftp|"); regex_sb.append("smb(?:s?)|"); regex_sb.append("smtp(?:s?)|"); regex_sb.append("svn(?:(?:\\+ssh)?)|"); regex_sb.append("tcp|"); regex_sb.append("telnet|"); regex_sb.append("tftp|"); regex_sb.append("udp|"); regex_sb.append("vnc|"); regex_sb.append("ws(?:s?)"); regex_sb.append("): regex_sb.append(")"); regex_sb.append("("); regex_sb.append("(?:\\S+(?::\\S*)?@)?"); regex_sb.append("(?:"); regex_sb.append("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|"); regex_sb.append("(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))?|"); regex_sb.append("/(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"); regex_sb.append(")"); regex_sb.append("(?::\\d{1,5})?"); regex_sb.append("(?:/[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append("(?:#[a-zA-Z0-9:@%\\-._~!$&()*+,;=?/]*)?"); regex_sb.append(")"); final Pattern urlPattern = Pattern.compile( regex_sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); LinkedHashSet<CharSequence> urlSet = new LinkedHashSet<>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); String url = text.substring(matchStart, matchEnd); urlSet.add(url); } return urlSet; }  boolean ensureStoragePermissionGranted(); @Override void onCreate(Bundle bundle); @Override void onServiceConnected(ComponentName componentName, IBinder service); void switchToSession(boolean forward); @Override void onServiceDisconnected(ComponentName name); @Override void onStart(); @Override void onBackPressed(); @Override void onDestroy(); @Override void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onContextItemSelected(MenuItem item); @Override void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults); TerminalSession getStoredCurrentSessionOrLast(); void removeFinishedSession(TerminalSession finishedSession); static final String TERMUX_FAILSAFE_SESSION_ACTION; }