- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to match a regular expression against a string?
Use the match() method to match a regular expression against a string in JavaScript. You can try to run the following code to match a regular expression −
The following is the parameter −
- match( param ) − A regular expression object.
Example
You can try to run the following code to match a regular expression against a string −
<html> <head> <title>JavaScript String match() Method</title> </head> <body> <script> var str = "For more information, see Chapter 3.4.5.1"; var re = /(chapter \d+(\.\d)*)/i; var found = str.match( re ); document.write(found ); </script> </body> </html>
Advertisements