Simple way to replace string in javscript with wildcards : Is there a simple way to replace something in a string in javascript with a wildcard but also use the wildcard in the resulting string:

So for example i have the String: 
   
    loop(10)
    {
       // do something
    }

an i want to replace the "loop" with a real for loop like this

    for(i=0; i<10; i++)
    {
       // do something
    }

but to do this i with a simple .replace i would need a wildcard. Obviously there is a solution to this problem but it seems very costly to me.


    