Lets say, we grabed a function call from somewhere and have it in a variable, Simply match the function name and parameters separately using regular expression and call the function using window object.
Using Regular expression( Regex ), We can check whether the given string has minimum no. of characters or whether it is inside specified range etc.
Generally, "replace" method in java script replaces only the first occurrence in the given string. We can change this behaviour by using regular expression.