What is the JavaScript equivalent of this .NET code?
var b = Regex.IsMatch(txt, pattern);
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.
Here are the useful functions for working with regexes.
execA RegExp method that executes a search for a match in a string. It returns an array of information.testA RegExp method that tests for a match in a string. It returns true or false.matchA String method that executes a search for a match in a string. It returns an array of information or null on a mismatch.searchA String method that tests for a match in a string. It returns the index of the match, or -1 if the search fails.replaceA String method that executes a search for a match in a string, and replaces the matched substring with a replacement substring.splitA String method that uses a regular expression or a fixed string to break a string into an array of substrings.Source: MDC
So to answer your question, as the others have said:
Or, if it is more convenient for your particular use, this is equivalent: