Find a pattern in an HTML comment using regex and javascript

I'm building a code generator/code editor and I'm trying to do a sort of Server Side Include but client side. I want to, using regex and javascript, parse out the "file attribute" in the line below, load the code in the "included" file and then replace the entire comment with that. I don't need help to do the loading only the regEx magic. :)

So first find the "file attribute". Then replace the entire comment with another string.

<!--#include file="footer.html" -->


var replace = function (str, process) {
     var regex = /<!--\s*#include\s+file="(.+)".*-->/g;
     return str.replace(regex, process);

var processFile = function (comment, filePath) {
    return 'content of the file';

var result = replace(
    'some text <!--#include file="footer.html" --> something else',

Need Your Help

Show a PopupWindow centralized

android android-layout popup

I have some popups on my app, it's fullscreen and the following code:

android live streaming of tv

android streaming live

I am developing app in which I have to implement live tv streaming. I am trying in internet but I am not getting good solutions . please help me to solve this..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.