At first glance it looks like this should work: $fcode =~ s/^\s*function\s+(?:\w+\(\)\s*)?\s*\{\s*\n//gi;
but I don't have any code to test it on. What do you expect to happen, and what is really happening? -----Original Message----- From: Kevin Old [mailto:[EMAIL PROTECTED] Sent: Thursday, March 23, 2006 11:17 AM To: Perl Beginners Subject: Javascript Regex to Perl Regex Hello everyone, I have a piece of javascript that formats a chunk of javascript into a "pretty print" version of it. I'd like to have a command line version of this, but can't seem to get the regexes to work in Perl. Just a long shot, but can anyone help with the conversion of them from JS to Perl? Here's the code: <html> <body> <script type="text/javascript"> function prettyScript(code) { try { var fcode = (new Function(code)).toString(); fcode = fcode.replace(/^\s*function\s+(?:\w+\(\)\s*)?\s*\{\s*\n/, ""); fcode = fcode.replace(/\s*}\s*$/, ""); return fcode; } catch (e) { return "SYNTAX ERROR: " + e.message; } } </script> <form action="" onsubmit="this.elements.output.value = prettyScript(this.elements.input.value); return false;"> <textarea id="input" cols="80" rows="5">"code to format here"</textarea><br> <input type="submit" value="format"><br> <textarea name="output" cols="80" rows="10" readonly="readonly">Output here</textarea><br> </form> </body> </html> Any help is appreciated, Kevin -- Kevin Old [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>