I have one string as string1= this is my name.
In string 1 find "is" i.e. Find string= "is"
replace string= "was"
final op=this was my name. Explain with c language.
I have one string as string1= this is my name.
In string 1 find "is" i.e. Find string= "is"
replace string= "was"
final op=this was my name. Explain with c language.
Something similar to this should do what you asked in many languages:
s = s.replace('is', 'was');
However on your example string this will give:
Thwas was my name
Note that This
has been changed to Thwas
because it contains the string is
. If you want to match only words rather than substrings you might want to use a regular expression instead and use word boundaries. In some languages you can use the following regular expression:
/\bis\b/
The syntax will vary slightly depending on the language.