如何模式匹配复杂的文件路径

时间:2019-11-20 16:55:33

标签: java regex

我正在使用Java8。我有一个场景,用户可以上传文档,并且必须比较上传的路径是否包含以下路径格式:

"/abc:doc_home{anyWord}/xyz:docFolder{anyWord}/[someWord]/def:library{anyWord}"

我需要上面和上面指示的花括号,其中可以包含任何单词。是否可以在正则表达式中执行此操作?

1 个答案:

答案 0 :(得分:-2)

您在表达式中两次包含了structure(list(sample = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c"), measurement = c(0.1443, 0.222, 0.333, 0.9435, 0.8051, 0.1554, 0.2775, 0.3885, 1.221, 1.8093, 0, 0, 0, 0.0333, 0.2997)), row.names = c(NA, -15L), na.action = structure(c(`1` = 1L, `2` = 2L, `3` = 3L, `5` = 5L, `6` = 6L, `8` = 8L, `9` = 9L, `11` = 11L, `12` = 12L, `15` = 15L, `16` = 16L, `17` = 17L, `18` = 18L, `20` = 20L, `21` = 21L, `23` = 23L, `24` = 24L, `26` = 26L, `27` = 27L, `30` = 30L, `31` = 31L, `32` = 32L, `33` = 33L, `35` = 35L, `36` = 36L, `38` = 38L, `39` = 39L, `41` = 41L, `42` = 42L, `45` = 45L), class = "omit"), class = "data.frame") 。如果您打算使这两个词相同词,那么不可以,正则表达式是不可能的。