I have a posList that contains an array of objects. I want to check if the entered value is an exact match of all the posCode in each object of the posList. My RegExp returns true when its a search match. For example, when 4325 is entered it returns true. I only want it to return true if the match is exact.
//short example
posList = [
    {
        posCode: "43252",
        description: "hi"
    },
    {
        posCode: "HTD632",
        description: "hello"
    }
]
checkPosCodeUnique = () => {
    const re = new RegExp(_.escapeRegExp(this.state.posCode), 'i');
    const isMatch = result => (re.test(result.posCode));
    const list = _.filter(this.state.posList, isMatch);
    if (list.length > 0) {
        error=true;
    }
};
 
     
     
     
    