C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript RegExp.prototype.toString() MethodThe toString() method returns a string which represents the regular expression. SyntaxRegExpObj.toString(); ParametersNA Return valueThis method returns the string representing the given object. Example 1var str = ""; var re = new RegExp( "","g" ); var result = re.toString(str); document.write("<br />Returned value : " + result); Output: Returned value : /(?:)/g Example 2document.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()); Output: /a+b+c/g/ gt+yu// abcd// \n/g Example 3var 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); Output: Returned value : /script/g Returned value : /(?:)/g
Next TopicJavaScript RegExp
|