TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript RegExp toString() Method

JavaScript RegExp toString() Methods with examples on javascript regexp methods, compile(), toSource(), test() method, toString(), exec(), @@match(), @@replace(), @@search(), @@split(), search(), match() etc.

<< Back to JAVASCRIPT

JavaScript RegExp.prototype.toString() Method

The toString() method returns a string which represents the regular expression.

Syntax

RegExpObj.toString();

Parameters

NA

Return value

This method returns the string representing the given object.

Example 1

var str = "";
   var re = new RegExp( "","g" );
         var result = re.toString(str);
         document.write("<br />Returned value : " +  result); 
Test it Now

Output:

Returned value : /(?:)/g

Example 2

document.write (new RegExp("a+b+c","g").toString());

document.write(new RegExp("<br\>gt+yu").toString());

document.write(new RegExp("<br\>abcd").toString());

document.write(new RegExp('<br\>\\n', 'g').toString());
Test it Now

Output:

/a+b+c/g/
gt+yu//
abcd//
\n/g

Example 3

var str = "scripting language";
 var re = new RegExp( "script", "g" );
           var result = re.toString(str);
         document.write("Returned value : " +  result); 

         re = new RegExp( "","g" );
          var result = re.toString(str);
         document.write("<br />Returned value : " +  result); 
Test it Now

Output:

Returned value : /script/g	
Returned value : /(?:)/g
Next TopicJavaScript RegExp




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf