I have a javascript array like
var main_array = ["allen~1", "ajay~2", "raj~3"];
I have another array like
var sub_array=["allen", "ajay"];
EDIT
I need to check whether each values of sub_array is found in main_array, (i.e) whether 'allen' found in ["allen~1", "ajay~2", "raj~3"] so the values which do not match must be removed from the array. As the result "raj~3" must be removed from the main_array
How to achieve this?
I have tried indexOf(), match() but that fails since it expects an exact match like "allen~1"..
Thanks in advance