import java.util.regex.Pattern;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "20131210_19045.csv,a.csv,";
System.out.println(""+Pattern.matches("(\\w*?\\W*?)*?(\\w?_\\d{4}.csv,)+(\\w*?\\W*?)*?", str));
}
}
------ Solution ------------------------------------- -------
try this
String str = "20131210_19015.csv,a.csv,";
System.out.println(""+Pattern.matches(".*(?<=_)(\\d{4})(?=.csv).*", str));
------ Solution ------------------------------------- -------
. *? _ \ \ d {4} \ \. csv. *
------ Solution -------------- ------------------------------
String str = "20131210_19045.csv,a.csv,";
System.out.println(str.matches(".*_\\d{4}\\.csv.*"));
------ Solution ---- ----------------------------------------
@Test
public void test()
{
String str = "20131210_19015.csv,a.csv,";
System.out.println(""+Pattern.matches(".*_\\d{4,}+\\.csv.*", str));
}
Although successful , but the feeling is still slow. . .
没有评论:
发表评论