Method to filter Map where regex ($)
is matched :
public Map getVariables(Map<String , String> nvp){
Map map = nvp.entrySet().parallelStream()
.filter(e -> e.getKey().matches("(($.*?))"))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return map;
}
Setup a map that contains key/value "($test)", "test value" :
private Map<String , String> nvp = new HashMap<String , String>();
public void setup(){
nvp.put("($test)", "test value");
}
Add a method to test that "($test)" is contained in the Map returned :
public void testGetVariables(){
OpDocVariableInsert o = new OpDocVariableInsert();
System.out.println(o.getVariables(nvp).size());
}
But 0 results are returned. I think my regex is incorrect ?