Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Newbee: Replace word (C#)

  •  10-17-2006, 5:31 AM

    Newbee: Replace word (C#)

    Hi

    I have a formulam represented like a string: @X1 + @Y2/ @X + @Y, where @xxx are variables which are replaced with a numeric value.

    Question 1: 
    Instead of myFormular.Replace("@X", "1234") I want to use a RegEx pattern to make sure that @X1 is not replaced when searching for @X. How do I do that?

    Question 2 (most important):
    Also, I want to search for remaining variables and replace them with 0. E.g. if my replaced formula looks like @X1 + 3/1234 + @Y I want @X1 and @Y to be replaced with 0, so the final formula looks like 0 + 3/1234 + 0.

    I know this is easy with RegEx, but I can't figure out how. Thanks for helping. 

    /Thomas

View Complete Thread