The RegExp toString() Method in JavaScript is used to return the string value of the regular expression.
Syntax:
RegExpObject.toString()
Example 1: This example returns the string value of the regular expression.
Javascript
function geek() {
let regex = new RegExp("[a-c]", "gi");
let rex = regex.toString();
console.log(rex);
}
geek()
|
Example 2: This example returns the string value of the regular expression.
Javascript
function geek() {
let regex = /[a-k]/g;
let rex = regex.toString();
console.log(rex);
}
geek()
|
Supported Browsers: The browsers supported by RegExp toString() Method are listed below:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Opera 5 and above
- Safari 1 and above
We have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Complete Reference article.
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
Learn to code easily with our course
Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated :
02 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...