如何为userID字段实现正则表达式?

时间:2015-10-15 12:06:26

标签: android regex

我有一个userID edittext字段,在这里我允许alphabets and numbers and '.' and '_' and '@' special characters。但是如何在edittext字段中仅限制'.' and '_' and '@'?我想这样限制:

  1. 仅限文字后,我想允许这些特殊字符。
  2. 只有一次我想允许那些喜欢的角色(不要允许两次像@@,..,__这样)
  3. userID的结尾没有spl字符。
  4. test.new_bike示例有效。
  5. test..new__bike,........,______,@@ @ @@ @喜欢我不会允许的话。
  6. 请帮助我,这是我的正则表达式

    ^(([A-Za-z0-9]+\\s{1}[A-Za-z0-9]+)|([A-Za-z0-9._]+))$
    

1 个答案:

答案 0 :(得分:1)

试试这个

public HBaseDataInsert() throws IOException {
    conf = HBaseConfiguration.create();
    hTable = new HTable(conf, "emp_java");
}

public void upload_transactionFile() throws IOException {

    String currentLine = null;
    BufferedReader br = new BufferedReader(
            new FileReader("transactionsFile.csv"));
    while ((currentLine = br.readLine()) != null) {
        System.out.println(currentLine);
        String[] line = currentLine.split(",");
        Put p = new Put(Bytes.toBytes(line[0] + "_" + line[1]));
        p.add(Bytes.toBytes("details"), Bytes.toBytes("Name"), Bytes.toBytes(line[0]));
        p.add(Bytes.toBytes("details"), Bytes.toBytes("id"), Bytes.toBytes(line[1]));
        p.add(Bytes.toBytes("details"), Bytes.toBytes("DATE"), Bytes.toBytes(line[2]));
        p.add(Bytes.toBytes("transaction details"), Bytes.toBytes("TRANSACTION_TYPE"), Bytes.toBytes(line[3]));

        hTable.put(p);
    }
    br.close();
    hTable.close();
}