Given an array of strings:
x = ["banana","apple","orange"]
is there a built in shortcut for performing wildcard searches?
ie., maybe
x.indexOf("*na*") //returns index of a string containing the substring na
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Expanding on Pim’s answer, the correct way to do it (without jQuery) would be this:
But really, unless you’re using this functionality in multiple places, you can just use the existing
filtermethod:The RegExp version is similar, but I think it will create a little bit more overhead:
It does provide the flexibility to allow you to specify a valid RegExp string, though.