Regex to remove content between brackets and preceding method name
I have:
xVal.AttachValidator("CoverSheet", {"Fields":[{"FieldName":"FromDateTime","FieldRules":[{"RuleName":"DataType","RuleParameters":{"Type":"Date"}}]},{"FieldName":"ToDateTime","FieldRules":[{"RuleName":"DataType","RuleParameters":{"Type":"Date"}},{"RuleName":"Custom","RuleParameters":{"Function":"ValidateDates","Parameters":"null"},"Message":""}]}]}, {})
and I need " "
So an easier example is:
function(param1)
function(params1, param2)
method(text)
function(ex1, ex2, ex3)
newmethod(text)
to become:
method(text)
newmethod(text)
I have these in htmlMarkup form that I need to write into a window.document but I need to remove certain methods first.
I don't care about the content between the brackets, but I must use "function" in the regex to identify which statement I want to remove. I've seen various variati开发者_Python百科ons of this but not quite what I need. Anybody?
I figured it out. I needed:
.replace(/ *xVal\.AttachValidator\([^)]*\) */g, ""));
精彩评论