开发者

Find and replce string [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that i开发者_如何学Got can be reopened, visit the help center. Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜