开发者

Regex to remove content between brackets and preceding method name

开发者 https://www.devze.com 2023-03-30 02:33 出处:网络
I have: xVal.AttachValidator(\"CoverSheet\", {\"Fields\":[{\"FieldName\":\"FromDateTime\",\"FieldRules\":[{\"RuleName\":\"DataType\",\"RuleParameters\":{\"Type\":\"Date\"}}]},{\"FieldName\":\"ToDateT

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, ""));
0

精彩评论

暂无评论...
验证码 换一张
取 消