Skip to content

Instantly share code, notes, and snippets.

@RX14
Created October 31, 2014 22:44
Show Gist options
  • Save RX14/f4f8946d49851ba5d300 to your computer and use it in GitHub Desktop.
Save RX14/f4f8946d49851ba5d300 to your computer and use it in GitHub Desktop.
int type = 0;
if (prefix.contains("!")) {
type = 1;
if (prefix.contains("@")) {
type = 2;
}
}
switch (type) {
case 0:
name = prefix;
break;
case 2:
int hostIndex = prefix.indexOf("@");
host = prefix.substring(hostIndex + 1);
prefix = prefix.substring(0, hostIndex - 1);
case 1:
int userIndex = prefix.indexOf("!");
name = prefix.substring(0, userIndex - 1);
user = prefix.substring(userIndex + 1);
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment