In this section, you will study the use of test() method. The test() method returns true if a pattern exists within a string, otherwise it returns false. This method searches a string for a specified value. You can see in the given example, we have used RegExp in order to search the specified pattern in the string. The expression pattern.test(st1) tests whether the specified pattern('@') exists in the Email ID or not.
Here is the code:
Output will be displayed as:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.