I have one lookup file like this
REGEXP|Name
^.*?AAA.*?$|POP
^.*?AAA.*?$|SOP
^.*?BBB.*?$|ZOP
^.*?CCC.*?$|ROP
I have input string and matching my input string with this lookup file with REGEXP column. And where ever it matches, Its returning Name.
Step 1 I'm loading lookup file in my tool like this
import java.util.Map;
import java.util.HashMap;
Map<String, String> regexMap = new HashMap<String, String>();
globalMap.put("regexMap", regexMap);
Step 2
Loading lookup file in hashmap like this
Map<String, String> regexMap = (Map<String, String>)globalMap.get("regexMap");
if( row1.REGEXP != null ) {
regexMap.put( row1.REGEXP, row1.Name);
}
Step 3
Hitting input string with this hashmap like this
Map<String, String> regexMap = (Map<String, String>)globalMap.get("regexMap");
for( String key : regexMap.keySet() ) {
if( input_row.data != null ) {
if( input_row.data.matches(key) ) {
output_row.Name = regexMap.get(key);
break;
}
}
}
I'm getting one value only. I want all values with matches with single key. Like in above mentioned lookup, If any string matches with first two REGEXP, output_row.Name should return POP and SOP both. Right now its returning only SOP.
Is any thing am missing like using Array list or doing something wrong.
Suggestion please?