tags:

views:

67

answers:

1

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.

+3  A: 

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.

Mark Byers
`+1` Way to answer something that isn't a question!
sshow
@Mark you didn't *justify your proof by dig* :-)
Darin Dimitrov
@Darin as you don't know what it means Mark could well have justified his proof by dig, repeatedly, by accident!
TooManyCooks
@TooManyCooks, agreed :-)
Darin Dimitrov