Search Results

Search found 2 results on 1 pages for 'shannow'.

Page 1/1 | 1 

  • c# Regex trouble

    - by Shannow
    Hi there, I'm having a bit of trouble with my regex. String a = @"{target=}jump"; String b = "continue"; String c = "jump"; String d = @"{target=intro}jump"; String e = "prev"; String f = @"{target=}choice"; String g = @"{target=intro}choice"; String h = "choice"; String i = "previous"; String j = @"{target=intro}continue"; String k = "cont"; String l = @"{target=}continue"; Regex regex = new Regex(@"(^{target=(\w.*)}(choice|jump))|(^[^.]*(continue|previous))"); var a_res = regex.IsMatch(a); var b_res = regex.IsMatch(b); var c_res = regex.IsMatch(c); var d_res = regex.IsMatch(d); var e_res = regex.IsMatch(e); var f_res = regex.IsMatch(f); var g_res = regex.IsMatch(g); var h_res = regex.IsMatch(h); var i_res = regex.IsMatch(i); var j_res = regex.IsMatch(j); var k_res = regex.IsMatch(k); var l_res = regex.IsMatch(l); Basically what i need is to get a match when choice or jump is present that it is proceeded by {target= } with any number of characters after the =. And also to match if continue or previous are present but only if they are proceeded by nothing. so A = false, b = true, c = false, d = true, e = false, f = false, g = true, h = false, i = true, j = false, k = false and l = false, with my regex above I get correct reading for everything bar j and l. Can anyone please help?

    Read the article

  • c# scope/typing/assignment question

    - by Shannow
    Hi there another quick question. I would like to create a variable object so that depending on the value of something, it gets cast as needed. e.g. var rule; switch (seqRuleObj.RuleType) { case SeqRuleObj.type.Pre : rule = new preConditionRuleType(); rule = (preConditionRuleType)seqRuleObj.Rule; break; case SeqRuleObj.type.Post : rule = new postConditionRuleType(); rule = (postConditionRuleType)seqRuleObj.Rule; break; case SeqRuleObj.type.Exit : rule = new exitConditionRuleType(); rule = (exitConditionRuleType)seqRuleObj.Rule; break; default : break; } String result; foreach (sequencingRuleTypeRuleConditionsRuleCondition cond in rule.ruleConditions.ruleCondition) { ....../ blah } so basically this will not work. c# will not allow me to create an new object in every case as the name is aleady defined. i can just paste the foreach loop into each case but that to me is such a waste, as the objects are exactly the same in all but name.

    Read the article

1