Since you only wanted to be specific to match fw-1 or fw-1.sq I assume your data set is going to be larger and more varied than what you have provided us so I have modified the regex to match fw-[0-9] and then look for end of string (which is denoted by a $ in regex) or fw-1 followed by .sq. This rule looks like ($|.sq$) which tells regexp to match end of line immediately or .sq then end of line.
var myArray =["pr-1.sq-1.reply-1",
"pr-1.sq-1.fw-1",
"pr-1.sq-1.fw-1.sq-1",
"pr-1.sq-1.fw-1.sq-1.receive-1",
"pr-1.sq-1.fw-1.sq-1.assign-1",
"pr-1.sq-1.fw-1.sq",
"pr-1.sq-1.fw-1.sq.receive-1"
];
var returningArray = [];
var myRegex = /\.fw-([1-9])($|\.sq$)/;
for(var i =0; i<myArray.length; i++){
if(myArray[i].match(myRegex)) {
returningArray.push(myArray[i]);
}
}
console.log(returningArray);
2
solved How to know if a string is ended RegularExpresion javascript [closed]