I want to replace
! = change
@ = static(does not)
$ = Want to replace
I got a sting like this @!$! How do I replace the $ with something else?
EDIT: I need to use Regex as the string may appear anywhere!
I want to replace
! = change
@ = static(does not)
$ = Want to replace
I got a sting like this @!$! How do I replace the $ with something else?
EDIT: I need to use Regex as the string may appear anywhere!
You don't need a regular expression, just use the String.Replace
method:
String result = input.Replace("$", "somethingElse");
As a side note: The way that you would do this with a regular expression would be like this:
String result = Regex.Replace(input, @"\$", "somethingElse");
Notice that I have escaped the $
with a backslash since $
usually means match the end of the string.
Using the String class' .Replace() method would do the trick but, if you really want to use RegEx, this is a great RegEx site that I use quite often.
You should be able to find what you're looking for there.
Why do you want some RegExp for string replacement. You can just use string.Replace() fundtion.
Take a look at System.Text.RegularExpressions.Regex.Replace method.
Regex.Replace("@!$!", "!(.*)!", "replacement value");