Skip to content

Instantly share code, notes, and snippets.

@shogonir
Created March 7, 2016 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shogonir/fab5e7e7448767437d9b to your computer and use it in GitHub Desktop.
Save shogonir/fab5e7e7448767437d9b to your computer and use it in GitHub Desktop.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class CheckHatenaID {
public static void main (String[] args) {
String hatenaID = "shogonir";
Pattern p = Pattern.compile("[a-zA-Z][a-zA-Z0-9_\\-]{1,30}[a-zA-Z0-9]");
Matcher m = p.matcher(hatenaID);
boolean f = m.matches();
System.out.println(String.valueOf(f));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment