

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 write a JavaScript RegExp to match an expression?
To match an expression, use the JavaScript match() method. This method is used to retrieve the matches when matching a string against a regular expression. The following is the parameter −
- param − A regular expression object.
If the regular expression does not include the g flag, it returns the same result as regexp.exec(string).
If the regular expression includes the g flag, the method returns an Array containing all the matches.
Example
You can try to run the following code to math an expression using JavaScript Regular Expression −
<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>
- Related Questions & Answers
- How to write a Python regular expression to match multiple words anywhere?
- How to write Python regular expression to match with file extension?
- How to write a regular expression to match either a or b in Python?
- How to write a JSP Expression?
- How to query an Array[String] for a Regular Expression match?
- How to write a Regular Expression in JavaScript to remove spaces?
- Regular expression to match numbers only in JavaScript?
- How to match a regular expression against a string?
- How to put variable in regular expression match with JavaScript?
- How to write JavaScript Regular Expression for multiple matches?
- How to write a conditional expression in lambda expression in Java?
- MongoDB regular expression to match a specific record?
- How to match a word in python using Regular Expression?
- How to match a whitespace in python using Regular Expression?
- How to match parentheses in Python regular expression?
Advertisements