@Test
public void testSplitFileRegex() throws Exception {

    String keyFileName = "exportkeys_test.keys";
    List<HRegionInfo> regionInfoList;
    byte[] splitPoint = "splitpoint".getBytes();
    splitTable(splitPoint);
    byte[] splitPoint2 = "splitpoint2".getBytes();
    String tableName2 = createAdditionalTable(tableName + "2");
    splitTable(tableName2, splitPoint2);
    byte[] splitPoint31 = Bytes.toBytes(3100L);
    byte[] splitPoint32 = Bytes.toBytes(3200L);
    String tableName3 = createAdditionalTable(tableName + "22");
    splitTable(tableName3, splitPoint31);
    splitTable(tableName3, splitPoint32);
    try {
        // export 3 tables
        String tableNameRegex = tableName + ".*";
        String[] argsParam = {"zookeeper", tableNameRegex, keyFileName};
        Args args = new ManagerArgs(argsParam);
        Assert.assertEquals("zookeeper", args.getZookeeperQuorum());
        Command command = new ExportKeys(admin, args);
        waitForSplitting(2);
        waitForSplitting(tableName2, 2);
        waitForSplitting(tableName3, 3);
        command.run();
        // merge all regions into one
        regionInfoList = getRegionInfoList(tableName);
        mergeRegion(regionInfoList.get(0), regionInfoList.get(1));
        assertEquals(1, getRegionInfoList(tableName).size());
        regionInfoList = getRegionInfoList(tableName2);
        mergeRegion(tableName2, regionInfoList.get(0), regionInfoList.get(1));
        assertEquals(1, getRegionInfoList(tableName2).size());
        regionInfoList = getRegionInfoList(tableName3);
        mergeRegion(tableName3, regionInfoList.get(0), regionInfoList.get(1));
        regionInfoList = getRegionInfoList(tableName3);
        mergeRegion(tableName3, regionInfoList.get(0), regionInfoList.get(1));
        assertEquals(1, getRegionInfoList(tableName3).size());
        // split
        tableNameRegex = tableName2 + ".*";
        String[] argsParam2 = {"zookeeper", tableNameRegex, "filE", keyFileName, "--force-proceed"};
        Args args2 = new ManagerArgs(argsParam2);
        assertEquals("zookeeper", args2.getZookeeperQuorum());
        command = new Split(admin, args2);
        command.run();
        waitForSplitting(tableName2, 2);
        waitForSplitting(tableName3, 3);
        ArrayList<HRegionInfo> regionInfoList1 = getRegionInfoList(tableName);
        ArrayList<HRegionInfo> regionInfoList2 = getRegionInfoList(tableName2);
        ArrayList<HRegionInfo> regionInfoList3 = getRegionInfoList(tableName3);
        assertEquals(1, regionInfoList1.size());
        assertEquals(2, regionInfoList2.size());
        assertArrayEquals(splitPoint2, regionInfoList2.get(1).getStartKey());
        assertEquals(3, regionInfoList3.size());
        assertArrayEquals(splitPoint31, regionInfoList3.get(1).getStartKey());
        assertArrayEquals(splitPoint32, regionInfoList3.get(2).getStartKey());
    } finally {
        Path filePath = Paths.get(keyFileName);
        if (Files.exists(filePath)) Files.delete(filePath);
    }
}