Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
hi
 
i have a string as example as shown below
 
setVar1_Variable.set(setVar1_Variable_Value, comment= 'setVar1_Variable_Comment', report= 0, format= '%s')
 
in this i want to find the string setVar1_Variable and want toreplace this string with new string ..
 
and dont want to make any change in setVar1_Variable_Value and 'setVar1_Variable_Comment'.
 
please help me on this.......
Posted 25-Jun-13 3:47am
rahuls11.1K
Comments
Nelek at 25-Jun-13 8:49am
   
rahuls1 at 25-Jun-13 8:54am
   
i worked with Replace it ia not working it is replacing every where even this also setVar1_Variable_Value which i dont want
ThePhantomUpvoter at 25-Jun-13 9:01am
   
You need to be more clear what your inputs are and what you expect your output to be. So far, nothing you have said makes any sense.
rahuls1 at 25-Jun-13 9:12am
   
setVar1_Variable.set(setVar1_Variable_Value, comment= 'setVar1_Variable_Comment', report= 0, format= '%s')

in this i want to find the string setVar1_Variable and want toreplace this string with new string ..

and dont want to make any change in setVar1_Variable_Value and 'setVar1_Variable_Comment'.
ThePhantomUpvoter at 25-Jun-13 9:57am
   
Repeating the same not clear explanation does not make anything you are trying to do more clear. You need to show us what the code is that you have tried, show us the actual values of setVar1_Variable, setVar1_Variable_Value and the rest and show us the expected result. Telling us that you are replacing a string in setVar1_Variable that is somehow affecting another variable makes no sense at all.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

String.Replace(string,string)[^]
 
string myString = "The word cool is replaced in this string";
string newString = myString.Replace("cool", "awesome");
 
newstring now equals "The word awesome is replaced in this string"
  Permalink  
Comments
rahuls1 at 25-Jun-13 8:53am
   
but is it has Cool_Value it will replace this also i dont want this ..
Ron Beyer at 25-Jun-13 9:13am
   
Then I would surround it with spaces, like myString.Replace(" cool ", " awesome ") which would replace the word "cool", but not "cool_value".
rahuls1 at 25-Jun-13 9:15am
   
please explain in detail i am not getting.......
rahuls1 at 25-Jun-13 9:18am
   
and i dont have hard codded value my string are not fixed it is some thing like this
 
Replace(List_ReplaceValue[j], List_ValueToReplace[j]))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 195
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 25 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100