具有 -, ::, ( 和 ) 的正则表达式
我需要拆分字符串
(age-is-25::OR::last_name-is-qa6)::AND::(age-is-20::OR::first_name-contains-test)
到
string[0] = (age-is-25::OR::last_name-is-qa6)
字符串[1] = AND
string[2] = (age-is-20::OR::first_name-contains-test)
我尝试编写这么多正则表达式,但没有任何东西可以按预期工作。
使用以下正则表达式,Matcher.groupCount() 返回 2,但将结果分配给数组列表返回 null 作为元素。
Pattern pattern = Pattern.compile(“(\\)::)?|(::\\()?");
我试图使用)::或::(拆分它。
我知道正则表达式看起来太愚蠢了,但作为一个初学者,这是我能写的最好的。